Remove write context (#7735)

~(currently built on top of #7732)~
This commit is contained in:
Trask Stalnaker 2023-02-06 09:34:12 -08:00 committed by GitHub
parent b9918ab513
commit 7be766a78b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 12 deletions

View File

@ -22,9 +22,6 @@ public class AttributeKeys {
}
};
public static final AttributeKey<Context> WRITE_CONTEXT =
attributeKey(AttributeKeys.class.getName() + ".write-context");
// this is the context that has the server span
public static final AttributeKey<Context> SERVER_CONTEXT =
attributeKey(AttributeKeys.class.getName() + ".server-context");

View File

@ -26,10 +26,7 @@ public class HttpClientRequestTracingHandler extends ChannelOutboundHandlerAdapt
return;
}
Context parentContext = ctx.channel().attr(AttributeKeys.WRITE_CONTEXT).getAndRemove();
if (parentContext == null) {
parentContext = Context.current();
}
Context parentContext = Context.current();
HttpRequestAndChannel request = HttpRequestAndChannel.create((HttpRequest) msg, ctx.channel());
if (!instrumenter().shouldStart(parentContext, request)) {

View File

@ -71,7 +71,8 @@ public final class NettyClientTelemetry {
* Propagate the {@link Context} to the {@link Channel}. This MUST be called before each HTTP
* request executed on a {@link Channel}.
*/
// TODO (trask) rename to setParentContext()?
public static void setChannelContext(Channel channel, Context context) {
channel.attr(AttributeKeys.WRITE_CONTEXT).set(context);
channel.attr(AttributeKeys.CLIENT_PARENT_CONTEXT).set(context);
}
}

View File

@ -14,9 +14,6 @@ import io.opentelemetry.context.Context;
*/
public final class AttributeKeys {
public static final AttributeKey<Context> WRITE_CONTEXT =
AttributeKey.valueOf(AttributeKeys.class, "passed-context");
// this is the context that has the server span
//
// note: this attribute key is also used by ratpack instrumentation

View File

@ -41,7 +41,7 @@ public class HttpClientRequestTracingHandler extends ChannelOutboundHandlerAdapt
return;
}
Context parentContext = ctx.channel().attr(AttributeKeys.WRITE_CONTEXT).getAndSet(null);
Context parentContext = ctx.channel().attr(AttributeKeys.CLIENT_PARENT_CONTEXT).get();
if (parentContext == null) {
parentContext = Context.current();
}