diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/client/BarService.java b/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/client/BarService.java index b5b612d3f6e1..80ea6133259f 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/client/BarService.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/client/BarService.java @@ -38,10 +38,7 @@ protected void generateSpan(StartEvent event) { httpClient .get(new URI(url)) .flatMap(response -> httpClient.get(new URI(url))) - .then( - response -> { - span.end(); - }); + .then(response -> span.end()); } catch (URISyntaxException e) { throw new RuntimeException(e); } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.java b/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.java index c13eebb2ee1e..3d7b7b2f4af8 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/java/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.java @@ -21,6 +21,7 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.ratpack.v1_7.RatpackServerTelemetry; +import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; import org.junit.jupiter.api.BeforeAll; @@ -34,6 +35,9 @@ class RatpackServerTest { @RegisterExtension private static final InstrumentationExtension testing = LibraryInstrumentationExtension.create(); + @RegisterExtension + private static final AutoCleanupExtension cleanup = AutoCleanupExtension.create(); + private static final RatpackServerTelemetry telemetry = RatpackServerTelemetry.builder(testing.getOpenTelemetry()).build(); @@ -52,6 +56,7 @@ void testAddSpanOnHandlers() throws Exception { spec.registry(registry); spec.handlers(chain -> chain.get("foo", ctx -> ctx.render("hi-foo"))); }); + cleanup.deferCleanup(app); assertThat(app.getHttpClient().get("foo").getBody().getText()).isEqualTo("hi-foo"); @@ -97,6 +102,7 @@ void testPropagateTraceWithInstrumentedAsyncOperations() throws Exception { .then(); })); }); + cleanup.deferCleanup(app); assertThat(app.getHttpClient().get("foo").getBody().getText()).isEqualTo("hi-foo"); @@ -162,6 +168,7 @@ void testPropagateTraceWithInstrumentedAsyncConcurrentOperations() throws Except }); }); }); + cleanup.deferCleanup(app); assertThat(app.getHttpClient().get("foo").getBody().getText()).isEqualTo("hi-foo"); assertThat(app.getHttpClient().get("bar").getBody().getText()).isEqualTo("hi-bar");