Skip to content

Commit 9c1a3be

Browse files
committed
null the context attrs after usage
1 parent 1e12563 commit 9c1a3be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

instrumentation/netty/netty-4.1/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_1/client/HttpClientResponseTracingHandler.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
120120
span.setStatus(code >= 100 && code < 400 ? StatusCode.UNSET : StatusCode.ERROR);
121121
}
122122
if (msg instanceof LastHttpContent) {
123+
// When we end the span, we should set the client context and client parent attr to null.
124+
// so that for the next request a new context is made and stored in channel.
125+
ctx.channel()
126+
.attr(io.opentelemetry.instrumentation.netty.v4_1.internal.AttributeKeys.CLIENT_CONTEXT)
127+
.set(null);
128+
ctx.channel()
129+
.attr(
130+
io.opentelemetry.instrumentation.netty.v4_1.internal.AttributeKeys
131+
.CLIENT_PARENT_CONTEXT)
132+
.set(null);
123133
span.end();
124134
}
125135
}

0 commit comments

Comments
 (0)