From 3fc21bf535790324ed4cd18904d1f5e566a1c516 Mon Sep 17 00:00:00 2001 From: Pavol Loffay
Span is not recording (Default) java.lang.Exception: Stack trace at + * java.lang.Thread.dumpStack(Thread.java:1336) at + * io.grpc.netty.Utils.convertClientHeaders(Utils.java:107) at + * io.grpc.netty.NettyClientStream$Sink.writeHeaders(NettyClientStream.java:124) at + * io.grpc.internal.AbstractClientStream.start(AbstractClientStream.java:132) at + * io.grpc.internal.DelayedStream$4.run(DelayedStream.java:197) at + * io.grpc.internal.DelayedStream.drainPendingCalls(DelayedStream.java:132) at + * io.grpc.internal.DelayedStream.setStream(DelayedStream.java:101) at + * io.grpc.internal.DelayedClientTransport$PendingStream.createRealStream(DelayedClientTransport.java:351) + * at + * io.grpc.internal.DelayedClientTransport$PendingStream.access$200(DelayedClientTransport.java:334) + * at io.grpc.internal.DelayedClientTransport$5.run(DelayedClientTransport.java:293) at + * io.grpc.stub.ClientCalls$ThreadlessExecutor.waitAndDrain(ClientCalls.java:575) (1) at + * + *
io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:120) at + * org.hypertrace.example.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:172) at + * io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcInstrumentationTest.serverRequestBlocking(GrpcInstrumentationTest.java:150) + * + *
Span is recording java.lang.Exception: Stack trace at + * java.lang.Thread.dumpStack(Thread.java:1336) at + * io.grpc.netty.Utils.convertClientHeaders(Utils.java:107) at + * io.grpc.netty.NettyClientStream$Sink.writeHeaders(NettyClientStream.java:124) at + * io.grpc.internal.AbstractClientStream.start(AbstractClientStream.java:132) at + * io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:225) at + * io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:32) at + * io.opentelemetry.instrumentation.grpc.v1_5.client.TracingClientInterceptor$TracingClientCall.start(TracingClientInterceptor.java:102) + * at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:261) at + * io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:237) at + * io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:171) at + * + *
io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:117) at + * org.hypertrace.example.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:172) at + * io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcInstrumentationTest.disabledInstrumentation_dynamicConfig(GrpcInstrumentationTest.java:182) + */ +@TestMethodOrder(OrderAnnotation.class) public class GrpcInstrumentationTest extends AbstractInstrumenterTest { private static final Helloworld.Request REQUEST = @@ -113,6 +160,7 @@ public void afterEach() { } @Test + @Order(2) public void blockingStub() throws IOException, TimeoutException, InterruptedException { Metadata headers = new Metadata(); headers.put(CLIENT_STRING_METADATA_KEY, "clientheader"); @@ -135,9 +183,13 @@ public void blockingStub() throws IOException, TimeoutException, InterruptedExce assertBodiesAndHeaders(clientSpan, requestJson, responseJson); SpanData serverSpan = spans.get(1); assertBodiesAndHeaders(serverSpan, requestJson, responseJson); + + assertHttp2HeadersForSayHelloMethod(serverSpan); + assertHttp2HeadersForSayHelloMethod(clientSpan); } @Test + @Order(1) public void serverRequestBlocking() throws TimeoutException, InterruptedException { Metadata blockHeaders = new Metadata(); blockHeaders.put(Metadata.Key.of("mockblock", Metadata.ASCII_STRING_MARSHALLER), "true"); @@ -167,9 +219,11 @@ public void serverRequestBlocking() throws TimeoutException, InterruptedExceptio serverSpan .getAttributes() .get(HypertraceSemanticAttributes.rpcRequestMetadata("mockblock"))); + assertHttp2HeadersForSayHelloMethod(serverSpan); } @Test + @Order(3) public void disabledInstrumentation_dynamicConfig() throws TimeoutException, InterruptedException { URL configUrl = getClass().getClassLoader().getResource("ht-config-all-disabled.yaml"); @@ -215,4 +269,24 @@ private void assertBodiesAndHeaders(SpanData span, String requestJson, String re HypertraceSemanticAttributes.rpcResponseMetadata( SERVER_STRING_METADATA_KEY.name()))); } + + private void assertHttp2HeadersForSayHelloMethod(SpanData span) { + Assertions.assertEquals( + "http", + span.getAttributes() + .get(HypertraceSemanticAttributes.rpcRequestMetadata(GrpcSemanticAttributes.SCHEME))); + Assertions.assertEquals( + "POST", + span.getAttributes() + .get(HypertraceSemanticAttributes.rpcRequestMetadata(GrpcSemanticAttributes.METHOD))); + Assertions.assertEquals( + String.format("localhost:%d", SERVER.getPort()), + span.getAttributes() + .get( + HypertraceSemanticAttributes.rpcRequestMetadata(GrpcSemanticAttributes.AUTHORITY))); + Assertions.assertEquals( + "/org.hypertrace.example.Greeter/SayHello", + span.getAttributes() + .get(HypertraceSemanticAttributes.rpcRequestMetadata(GrpcSemanticAttributes.PATH))); + } } From aa99746098c6be3be547e1bb712e71c2811c2ac7 Mon Sep 17 00:00:00 2001 From: Pavol Loffay
Span is not recording (Default) java.lang.Exception: Stack trace at - * java.lang.Thread.dumpStack(Thread.java:1336) at - * io.grpc.netty.Utils.convertClientHeaders(Utils.java:107) at - * io.grpc.netty.NettyClientStream$Sink.writeHeaders(NettyClientStream.java:124) at - * io.grpc.internal.AbstractClientStream.start(AbstractClientStream.java:132) at - * io.grpc.internal.DelayedStream$4.run(DelayedStream.java:197) at - * io.grpc.internal.DelayedStream.drainPendingCalls(DelayedStream.java:132) at - * io.grpc.internal.DelayedStream.setStream(DelayedStream.java:101) at - * io.grpc.internal.DelayedClientTransport$PendingStream.createRealStream(DelayedClientTransport.java:351) - * at - * io.grpc.internal.DelayedClientTransport$PendingStream.access$200(DelayedClientTransport.java:334) - * at io.grpc.internal.DelayedClientTransport$5.run(DelayedClientTransport.java:293) at - * io.grpc.stub.ClientCalls$ThreadlessExecutor.waitAndDrain(ClientCalls.java:575) (1) at - * - *
io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:120) at - * org.hypertrace.example.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:172) at - * io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcInstrumentationTest.serverRequestBlocking(GrpcInstrumentationTest.java:150) - * - *
Span is recording java.lang.Exception: Stack trace at - * java.lang.Thread.dumpStack(Thread.java:1336) at - * io.grpc.netty.Utils.convertClientHeaders(Utils.java:107) at - * io.grpc.netty.NettyClientStream$Sink.writeHeaders(NettyClientStream.java:124) at - * io.grpc.internal.AbstractClientStream.start(AbstractClientStream.java:132) at - * io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:225) at - * io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:32) at - * io.opentelemetry.instrumentation.grpc.v1_5.client.TracingClientInterceptor$TracingClientCall.start(TracingClientInterceptor.java:102) - * at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:261) at - * io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:237) at - * io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:171) at - * - *
io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:117) at - * org.hypertrace.example.GreeterGrpc$GreeterBlockingStub.sayHello(GreeterGrpc.java:172) at - * io.opentelemetry.instrumentation.hypertrace.grpc.v1_5.GrpcInstrumentationTest.disabledInstrumentation_dynamicConfig(GrpcInstrumentationTest.java:182) + * TODO the HTTP2 headers for client does not work for the first request - therefore the ordering + * https://github.com/hypertrace/javaagent/issues/109#issuecomment-740918018 */ @TestMethodOrder(OrderAnnotation.class) public class GrpcInstrumentationTest extends AbstractInstrumenterTest { From 960b66075af14b499c19bf53eb75b143f1e6f016 Mon Sep 17 00:00:00 2001 From: Pavol Loffay
The client side HTTP2 headers are added directly to span in {@link + * Utils_convertClientHeaders_Advice}. TODO However it does not work for the first request + * https://github.com/hypertrace/javaagent/issues/109#issuecomment-740918018. + */ class NettyUtilsInstrumentation implements TypeInstrumentation { - @Override public ElementMatcher super TypeDescription> typeMatcher() { return failSafe(named("io.grpc.netty.Utils")); diff --git a/instrumentation/grpc-1.5/src/test/java/io/opentelemetry/instrumentation/hypertrace/grpc/v1_5/GrpcInstrumentationTest.java b/instrumentation/grpc-1.5/src/test/java/io/opentelemetry/instrumentation/hypertrace/grpc/v1_5/GrpcInstrumentationTest.java index 864ab15bf..a4fa297b9 100644 --- a/instrumentation/grpc-1.5/src/test/java/io/opentelemetry/instrumentation/hypertrace/grpc/v1_5/GrpcInstrumentationTest.java +++ b/instrumentation/grpc-1.5/src/test/java/io/opentelemetry/instrumentation/hypertrace/grpc/v1_5/GrpcInstrumentationTest.java @@ -54,8 +54,8 @@ import org.junit.jupiter.api.TestMethodOrder; /** - * TODO the HTTP2 headers for client does not work for the first request - therefore the ordering - * https://github.com/hypertrace/javaagent/issues/109#issuecomment-740918018 + * TODO the HTTP2 headers for client does not work for the first request - therefore the explicit + * ordering https://github.com/hypertrace/javaagent/issues/109#issuecomment-740918018 */ @TestMethodOrder(OrderAnnotation.class) public class GrpcInstrumentationTest extends AbstractInstrumenterTest { From 35f895183a35eba820206dc3d18792f76e8a1974 Mon Sep 17 00:00:00 2001 From: Pavol Loffay
We cannot use prefix because e.g. ht.:path is not a valid key.
+ */
+ private static final String SUFFIX = "ht";
+
public static final Metadata.Key We cannot use prefix because e.g. ht.:path is not a valid key.
*/
- private static final String SUFFIX = "ht";
+ private static final String SUFFIX = ".ht";
public static final Metadata.Key