Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeluca committed Jan 4, 2025
1 parent 6d6a93f commit 546afe3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -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");

Expand Down Expand Up @@ -97,6 +102,7 @@ void testPropagateTraceWithInstrumentedAsyncOperations() throws Exception {
.then();
}));
});
cleanup.deferCleanup(app);

assertThat(app.getHttpClient().get("foo").getBody().getText()).isEqualTo("hi-foo");

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 546afe3

Please sign in to comment.