diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/RatpackFunctionalTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/RatpackFunctionalTest.groovy index 6d4bf8fc834c..396ed15173e1 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/RatpackFunctionalTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/RatpackFunctionalTest.groovy @@ -8,16 +8,23 @@ package io.opentelemetry.instrumentation.ratpack import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter import io.opentelemetry.sdk.trace.export.SpanExporter +import ratpack.guice.BindingsImposition import ratpack.impose.ForceDevelopmentImposition import ratpack.impose.ImpositionsSpec import ratpack.impose.UserRegistryImposition import ratpack.registry.Registry import ratpack.test.MainClassApplicationUnderTest +import ratpack.test.embed.EmbeddedApp class RatpackFunctionalTest extends MainClassApplicationUnderTest { Registry registry @Lazy InMemorySpanExporter spanExporter = registry.get(SpanExporter) as InMemorySpanExporter + @Lazy EmbeddedApp app = EmbeddedApp.of { server -> + server.handlers { chain -> + chain.get("other") { ctx -> ctx.render("hi-other") } + } + } RatpackFunctionalTest(Class mainClass) { super(mainClass) @@ -31,5 +38,8 @@ class RatpackFunctionalTest extends MainClassApplicationUnderTest { registry = r registry }) + impositions.add(BindingsImposition.of { + it.bindInstance(URI, app.address.resolve("other")) + }) } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackServerApplicationTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackServerApplicationTest.groovy index dc6c0649b94b..80e1696c3502 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackServerApplicationTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/server/RatpackServerApplicationTest.groovy @@ -138,21 +138,15 @@ class OpenTelemetryModule extends AbstractModule { @Singleton @Provides - ExecInitializer ratpackExecInitializer(RatpackHttpTracing ratpackTracing) { - return ratpackTracing.getOpenTelemetryExecInitializer() + ExecInitializer ratpackExecInitializer(RatpackHttpTracing ratpackHttpTracing) { + return ratpackHttpTracing.getOpenTelemetryExecInitializer() } - } +@CompileStatic class RatpackApp { static void main(String... args) { - def other = RatpackServer.start { server -> - server.handlers { chain -> - chain.get("other") { ctx -> ctx.render("hi-other") } - } - } - RatpackServer.start { server -> server .registry(Guice.registry { b -> b.module(OpenTelemetryModule) }) @@ -162,8 +156,7 @@ class RatpackApp { .all(OpenTelemetryServerHandler) .get("foo") { ctx -> ctx.render("hi-foo") } .get("bar") { ctx -> - def instrumentedHttpClient = ctx.get(HttpClient) - instrumentedHttpClient.get(new URI("http://${other.bindHost}:${other.bindPort}/other")) + ctx.get(HttpClient).get(ctx.get(URI)) .then { ctx.render("hi-bar") } } }