diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java index 00518a652b1d..7d8c814fc7c6 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java @@ -1508,12 +1508,16 @@ public void sayHello( executor.execute( () -> { - try { - backendStub.sayHello(request); - } catch (Throwable t) { - error.set(t); - } - clientCallDone.countDown(); + // Execute in ROOT context to avoid cancelled context propagation + io.grpc.Context.ROOT.run( + () -> { + try { + backendStub.sayHello(request); + } catch (Throwable t) { + error.set(t); + } + clientCallDone.countDown(); + }); }); } })) @@ -1533,7 +1537,9 @@ public void sayHello( // for the two cases due to lack of context propagation in the library case, but that isn't what // we're testing here. - clientCallDone.await(10, SECONDS); + assertThat(clientCallDone.await(10, SECONDS)) + .as("client call should complete within timeout") + .isTrue(); assertThat(error).hasValue(null); }