Propagate client span context in doOnRequest
Copying the changes from Mike W. This fixes the problem where the jaxrs
and http client request spans are siblings instead of parent/child.
please review
MODIFY
instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/HttpClientInstrumentation.java
instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/HttpClientInstrumentation.java
@@ -85,7 +85,9 @@ public class HttpClientInstrumentation implements TypeInstrumentation {
BiConsumer<? super HttpClientRequest, ? super Connection> callback) {
if (DecoratorFunctions.shouldDecorate(callback.getClass())) {
- callback = new DecoratorFunctions.OnMessageDecorator<>(callback, PropagatedContext.PARENT);
+ // perform the callback with the client span active (instead of the parent) since this
+ // callback occurs after the connection is made
+ callback = new DecoratorFunctions.OnMessageDecorator<>(callback, PropagatedContext.CLIENT);
}
}
}

MODIFY
instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/AbstractReactorNettyHttpClientTest.java
instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/AbstractReactorNettyHttpClientTest.java
@@ -180,7 +180,7 @@ abstract class AbstractReactorNettyHttpClientTest
span -> span.hasName("HTTP GET").hasKind(CLIENT).hasParent(parentSpan),
span -> span.hasName("test-http-server").hasKind(SERVER).hasParent(nettyClientSpan));
- assertSameSpan(parentSpan, onRequestSpan);
+ assertSameSpan(nettyClientSpan, onRequestSpan);
assertSameSpan(nettyClientSpan, afterRequestSpan);
assertSameSpan(nettyClientSpan, onResponseSpan);
assertSameSpan(parentSpan, afterResponseSpan);

Propagate client span context in doOnRequest (#6621)

Copying the changes from Mike W. This fixes the problem where the jaxrs
and http client request spans are siblings instead of parent/child.

@mateuszrzeszutek please review

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>