diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/client/OpenTelemetryHttpClient.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/client/OpenTelemetryHttpClient.java index c7e672eac9aa..936e4630f226 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/client/OpenTelemetryHttpClient.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/client/OpenTelemetryHttpClient.java @@ -36,8 +36,8 @@ public HttpClient instrument(HttpClient httpClient) throws Exception { Context otelCtx = instrumenter.start(parentOtelCtx, requestSpec); Span span = Span.fromContext(otelCtx); String path = requestSpec.getUri().getPath(); -// span.updateName(path); - span.updateName("HTTP " + requestSpec.getMethod().getName()); + span.updateName(path); +// span.updateName("HTTP " + requestSpec.getMethod().getName()); // TODO use path instead of [HTTP method] span.setAttribute(SemanticAttributes.HTTP_ROUTE, path); Execution.current() .add(new OpenTelemetryExecInitializer.ContextHolder(otelCtx, requestSpec)); diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/client/InstrumentedHttpClientTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/client/InstrumentedHttpClientTest.groovy index 8264e08e7bbe..0d7d94aaa733 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/client/InstrumentedHttpClientTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/client/InstrumentedHttpClientTest.groovy @@ -49,6 +49,11 @@ class InstrumentedHttpClientTest extends Specification { def "propagate trace with http calls"() { expect: def otherApp = EmbeddedApp.of { spec -> + spec.registry( + Guice.registry { bindings -> + ratpackTracing.configureServerRegistry(bindings) + } + ) spec.handlers { it.get("bar") { ctx -> ctx.render("foo") } } @@ -78,9 +83,11 @@ class InstrumentedHttpClientTest extends Specification { new PollingConditions().eventually { def spanData = spanExporter.finishedSpanItems.find { it.name == "/foo" } - def spanClientData = spanExporter.finishedSpanItems.find { it.name == "/bar" } + def spanClientData = spanExporter.finishedSpanItems.find { it.name == "/bar" && it.kind == SpanKind.CLIENT } + def spanDataApi = spanExporter.finishedSpanItems.find { it.name == "/bar" && it.kind == SpanKind.SERVER } spanData.traceId == spanClientData.traceId + spanData.traceId == spanDataApi.traceId spanData.kind == SpanKind.SERVER spanClientData.kind == SpanKind.CLIENT @@ -94,6 +101,12 @@ class InstrumentedHttpClientTest extends Specification { attributes[SemanticAttributes.HTTP_TARGET] == "/foo" attributes[SemanticAttributes.HTTP_METHOD] == "GET" attributes[SemanticAttributes.HTTP_STATUS_CODE] == 200L + + def attsApi = spanDataApi.attributes.asMap() + attsApi[SemanticAttributes.HTTP_ROUTE] == "/bar" + attsApi[SemanticAttributes.HTTP_TARGET] == "/bar" + attsApi[SemanticAttributes.HTTP_METHOD] == "GET" + attsApi[SemanticAttributes.HTTP_STATUS_CODE] == 200L } }