Fix Operation name logging for Netty based applications
MODIFY
instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/HttpServerRequestTracingHandler.java
instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/HttpServerRequestTracingHandler.java
@@ -46,7 +46,9 @@ public class HttpServerRequestTracingHandler extends SimpleChannelUpstreamHandle
HttpRequest request = (HttpRequest) message;
Context context =
- tracer().startSpan(request, ctx.getChannel(), channelTraceContext, "netty.request");
+ tracer()
+ .startSpan(
+ request, ctx.getChannel(), channelTraceContext, "HTTP " + request.getMethod());
try (Scope ignored = context.makeCurrent()) {
ctx.sendUpstream(event);
// the span is ended normally in HttpServerResponseTracingHandler

MODIFY
instrumentation/netty/netty-3.8/javaagent/src/test/groovy/Netty38ServerTest.groovy
instrumentation/netty/netty-3.8/javaagent/src/test/groovy/Netty38ServerTest.groovy
@@ -143,6 +143,6 @@ class Netty38ServerTest extends HttpServerTest<ServerBootstrap> implements Agent
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
- return "netty.request"
+ return "HTTP GET"
}
}

MODIFY
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/HttpServerRequestTracingHandler.java
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/HttpServerRequestTracingHandler.java
@@ -32,7 +32,8 @@ public class HttpServerRequestTracingHandler extends ChannelInboundHandlerAdapte
return;
}
- Context context = tracer().startSpan((HttpRequest) msg, channel, channel, "netty.request");
+ HttpRequest request = (HttpRequest) msg;
+ Context context = tracer().startSpan(request, channel, channel, "HTTP " + request.getMethod());
try (Scope ignored = context.makeCurrent()) {
ctx.fireChannelRead(msg);
// the span is ended normally in HttpServerResponseTracingHandler

MODIFY
instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ServerTest.groovy
instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ServerTest.groovy
@@ -115,6 +115,6 @@ class Netty40ServerTest extends HttpServerTest<EventLoopGroup> implements AgentT
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
- return "netty.request"
+ return "HTTP GET"
}
}

MODIFY
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/server/HttpServerRequestTracingHandler.java
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/server/HttpServerRequestTracingHandler.java
@@ -32,7 +32,8 @@ public class HttpServerRequestTracingHandler extends ChannelInboundHandlerAdapte
return;
}
- Context context = tracer().startSpan((HttpRequest) msg, channel, channel, "netty.request");
+ HttpRequest request = (HttpRequest) msg;
+ Context context = tracer().startSpan(request, channel, channel, "HTTP " + request.method());
try (Scope ignored = context.makeCurrent()) {
ctx.fireChannelRead(msg);
// the span is ended normally in HttpServerResponseTracingHandler

MODIFY
instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ServerTest.groovy
instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ServerTest.groovy
@@ -114,6 +114,6 @@ class Netty41ServerTest extends HttpServerTest<EventLoopGroup> implements AgentT
@Override
String expectedServerSpanName(ServerEndpoint endpoint) {
- return "netty.request"
+ return "HTTP GET"
}
}

Fix Operation name logging for Netty based applications (#2317)