Skip to content

Commit ad31891

Browse files
authored
Try to improve stability of finagle test (#10923)
1 parent 275188a commit ad31891

File tree

1 file changed

+4
-1
lines changed
  • instrumentation/finagle-http-23.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11

1 file changed

+4
-1
lines changed

instrumentation/finagle-http-23.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/ClientTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import io.netty.handler.codec.http2.Http2StreamFrameToHttpObjectCodec;
2323
import io.netty.handler.timeout.ReadTimeoutException;
2424
import io.opentelemetry.api.common.AttributeKey;
25+
import io.opentelemetry.context.Context;
26+
import io.opentelemetry.context.Scope;
2527
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
2628
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest;
2729
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension;
@@ -85,10 +87,11 @@ private Future<Response> doSendRequest(Request request, URI uri) {
8587
// push this onto a FuturePool for 2 reasons:
8688
// 1) forces the request handling onto a different thread, ensuring test accuracy
8789
// 2) using the default thread can mess with high concurrency scenarios
90+
Context context = Context.current();
8891
return FuturePool.unboundedPool()
8992
.apply(
9093
() -> {
91-
try {
94+
try (Scope ignored = context.makeCurrent()) {
9295
return Await.result(getClient(uri).apply(request));
9396
} catch (Exception e) {
9497
throw new RuntimeException(e);

0 commit comments

Comments
 (0)