Netty connection failure span only when first operation fails
MODIFY
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/ChannelFutureListenerInstrumentation.java
instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/ChannelFutureListenerInstrumentation.java
@@ -50,14 +50,14 @@ public class ChannelFutureListenerInstrumentation implements TypeInstrumentation
- To return scope only if we have captured it.
- To capture scope only in case of error.
*/
- Throwable cause = future.cause();
- if (cause == null) {
- return null;
- }
Context parentContext = future.channel().attr(AttributeKeys.CONNECT_CONTEXT).getAndRemove();
if (parentContext == null) {
return null;
}
+ Throwable cause = future.cause();
+ if (cause == null) {
+ return null;
+ }
Scope parentScope = parentContext.makeCurrent();
if (tracer().shouldStartSpan(parentContext)) {

MODIFY
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/ChannelFutureListenerInstrumentation.java
instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/ChannelFutureListenerInstrumentation.java
@@ -52,14 +52,14 @@ public class ChannelFutureListenerInstrumentation implements TypeInstrumentation
- To return scope only if we have captured it.
- To capture scope only in case of error.
*/
- Throwable cause = future.cause();
- if (cause == null) {
- return null;
- }
Context parentContext = future.channel().attr(AttributeKeys.CONNECT_CONTEXT).getAndRemove();
if (parentContext == null) {
return null;
}
+ Throwable cause = future.cause();
+ if (cause == null) {
+ return null;
+ }
Scope parentScope = parentContext.makeCurrent();
if (tracer().shouldStartSpan(parentContext, SpanKind.CLIENT)) {

Netty connection failure span only when first operation fails (#3228)