From 21bd03f247484722bd967fbc8db772f6b2159bb1 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Mon, 28 Feb 2022 18:00:36 +0000 Subject: [PATCH] Consistent Span name and http.route.name --- .../deployment/tracing/TracerProcessor.java | 10 +- .../deployment/OpenTelemetryDevModeTest.java | 2 +- .../deployment/OpenTelemetryHttpCDITest.java | 2 +- .../deployment/OpenTelemetryResourceTest.java | 2 +- .../RestClientOpenTelemetryTest.java | 12 +-- .../VertxClientOpenTelemetryTest.java | 4 +- .../deployment/VertxOpenTelemetryTest.java | 2 +- .../restclient/OpenTelemetryClientFilter.java | 6 +- .../vertx/HttpInstrumenterVertxTracer.java | 94 +++++++++---------- .../OpenTelemetryReactiveClientTest.java | 4 +- .../opentelemetry/vertx/HelloRouterTest.java | 8 +- .../it/opentelemetry/vertx/SqlClientTest.java | 2 +- .../opentelemetry/OpenTelemetryTestCase.java | 44 ++++----- .../io/quarkus/it/rest/client/BasicTest.java | 8 +- 14 files changed, 94 insertions(+), 106 deletions(-) diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/TracerProcessor.java b/extensions/opentelemetry/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/TracerProcessor.java index cb9bcf0f93347..688808b2655f4 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/TracerProcessor.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/tracing/TracerProcessor.java @@ -151,8 +151,7 @@ void dropNames(Optional staticResources, if (config.isPropertyPresent("quarkus.http.root-path")) { String rootPath = config.getValue("quarkus.http.root-path", new NormalizeRootHttpPathConverter()); String nonApplicationRootPath = config.getRawValue("quarkus.http.non-application-root-path"); - // span names don't include the leading slash - nonApplicationUris.add(rootPath.substring(1) + nonApplicationRootPath); + nonApplicationUris.add(rootPath + nonApplicationRootPath); } dropNonApplicationUris.produce(new DropNonApplicationUrisBuildItem(nonApplicationUris)); @@ -161,12 +160,7 @@ void dropNames(Optional staticResources, if (staticResources.isPresent()) { for (StaticResourcesBuildItem.Entry entry : staticResources.get().getEntries()) { if (!entry.isDirectory()) { - // span names don't include the leading slash - if (entry.getPath().startsWith("/") && entry.getPath().length() > 1) { - resources.add(entry.getPath().substring(1)); - } else { - resources.add(entry.getPath()); - } + resources.add(entry.getPath()); } } } diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java index d4f3dee4bed1a..80066dd997dc8 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java @@ -23,7 +23,7 @@ void testDevMode() { //and the hot replacement stuff is not messing things up RestAssured.when().get("/hello").then() .statusCode(200) - .body(is("hello")); + .body(is("/hello")); RestAssured.when().get("/tracer").then() .statusCode(200) diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryHttpCDITest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryHttpCDITest.java index b3da967c6bdfa..a3f71b43702f8 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryHttpCDITest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryHttpCDITest.java @@ -44,7 +44,7 @@ void telemetry() { List spans = spanExporter.getFinishedSpanItems(2); assertEquals("HelloBean.hello", spans.get(0).getName()); assertEquals(INTERNAL, spans.get(0).getKind()); - assertEquals("hello", spans.get(1).getName()); + assertEquals("/hello", spans.get(1).getName()); assertEquals(SERVER, spans.get(1).getKind()); assertEquals(spans.get(0).getParentSpanId(), spans.get(1).getSpanId()); } diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryResourceTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryResourceTest.java index fc84e7c3ed22b..b4d61f4767c10 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryResourceTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryResourceTest.java @@ -41,7 +41,7 @@ void resource() { .body(is("hello")); List spans = spanExporter.getFinishedSpanItems(1); - assertEquals("hello", spans.get(0).getName()); + assertEquals("/hello", spans.get(0).getName()); assertEquals(SERVER, spans.get(0).getKind()); assertEquals("authservice", spans.get(0).getResource().getAttribute(AttributeKey.stringKey("service.name"))); assertEquals(config.getRawValue("quarkus.uuid"), diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/RestClientOpenTelemetryTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/RestClientOpenTelemetryTest.java index d9991a609a079..2d389d51ffe42 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/RestClientOpenTelemetryTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/RestClientOpenTelemetryTest.java @@ -62,7 +62,7 @@ void client() { SpanData server = spans.get(0); assertEquals(SERVER, server.getKind()); - assertEquals("hello", server.getName()); + assertEquals("/hello", server.getName()); assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD)); assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE)); @@ -71,7 +71,7 @@ void client() { SpanData client = spans.get(1); assertEquals(CLIENT, client.getKind()); - assertEquals("hello", client.getName()); + assertEquals("/hello", client.getName()); assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD)); assertEquals(uri.toString() + "hello", client.getAttributes().get(HTTP_URL)); @@ -89,7 +89,7 @@ void spanNameWithoutQueryString() { SpanData client = spans.get(1); assertEquals(CLIENT, client.getKind()); - assertEquals("hello", client.getName()); + assertEquals("/hello", client.getName()); assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD)); assertEquals(uri.toString() + "hello?query=1", client.getAttributes().get(HTTP_URL)); @@ -109,7 +109,7 @@ void urlWithoutAuthentication() { SpanData client = spans.get(1); assertEquals(CLIENT, client.getKind()); - assertEquals("hello", client.getName()); + assertEquals("/hello", client.getName()); assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD)); assertEquals(uri.toString() + "hello?query=1", client.getAttributes().get(HTTP_URL)); @@ -127,7 +127,7 @@ void path() { SpanData server = spans.get(0); assertEquals(SERVER, server.getKind()); - assertEquals("hello/{path}", server.getName()); + assertEquals("/hello/{path}", server.getName()); assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD)); assertEquals("/hello/{path}", server.getAttributes().get(HTTP_ROUTE)); @@ -136,7 +136,7 @@ void path() { SpanData client = spans.get(1); assertEquals(CLIENT, client.getKind()); - assertEquals("hello/{path}", client.getName()); + assertEquals("/hello/{path}", client.getName()); assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD)); assertEquals(uri.toString() + "hello/another", client.getAttributes().get(HTTP_URL)); diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxClientOpenTelemetryTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxClientOpenTelemetryTest.java index d8f7f6334b1e7..1760daff376a2 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxClientOpenTelemetryTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxClientOpenTelemetryTest.java @@ -64,7 +64,7 @@ void client() throws Exception { SpanData server = spans.get(0); assertEquals(SERVER, server.getKind()); - assertEquals("hello", server.getName()); + assertEquals("/hello", server.getName()); assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD)); assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE)); @@ -96,7 +96,7 @@ void path() throws Exception { SpanData server = spans.get(0); assertEquals(SERVER, server.getKind()); - assertEquals("hello/:name", server.getName()); + assertEquals("/hello/:name", server.getName()); assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE)); assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD)); assertEquals("/hello/:name", server.getAttributes().get(HTTP_ROUTE)); diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxOpenTelemetryTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxOpenTelemetryTest.java index 40652a7d36692..e319dc5811ba6 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxOpenTelemetryTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/VertxOpenTelemetryTest.java @@ -90,7 +90,7 @@ void spanNameWithoutQueryString() { assertEquals("io.quarkus.vertx.opentelemetry", spans.get(0).getName()); assertEquals("hello!", spans.get(0).getAttributes().get(stringKey("test.message"))); - assertEquals("tracer", spans.get(1).getName()); + assertEquals("/tracer", spans.get(1).getName()); assertEquals(200, spans.get(1).getAttributes().get(HTTP_STATUS_CODE)); assertEquals("1.1", spans.get(1).getAttributes().get(HTTP_FLAVOR)); assertEquals("/tracer?id=1", spans.get(1).getAttributes().get(HTTP_TARGET)); diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/restclient/OpenTelemetryClientFilter.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/restclient/OpenTelemetryClientFilter.java index 8be764b6ac3fd..108b3d5f2873f 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/restclient/OpenTelemetryClientFilter.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/restclient/OpenTelemetryClientFilter.java @@ -123,12 +123,12 @@ private static class ClientSpanNameExtractor implements SpanNameExtractor 1) { - return pathTemplate.substring(1); + return pathTemplate; } String uriPath = request.getUri().getPath(); - if (uriPath.length() > 1) { - return uriPath.substring(1); + if (uriPath != null && uriPath.length() > 1) { + return uriPath; } return "HTTP " + request.getMethod(); diff --git a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java index 9cfd1085ee74f..4e0cee99550f9 100644 --- a/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/vertx/HttpInstrumenterVertxTracer.java @@ -1,25 +1,24 @@ package io.quarkus.opentelemetry.runtime.tracing.vertx; +import static io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteSource.FILTER; import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_CLIENT_IP; -import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_ROUTE; import static io.quarkus.opentelemetry.runtime.OpenTelemetryConfig.INSTRUMENTATION_NAME; -import java.net.URI; import java.util.List; import java.util.function.BiConsumer; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.api.trace.Span; import io.opentelemetry.context.Scope; import io.opentelemetry.context.propagation.TextMapGetter; import io.opentelemetry.context.propagation.TextMapSetter; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteGetter; +import io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteHolder; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; @@ -81,6 +80,19 @@ public OpenTelemetryVertxTracer.SpanOperation spanOperation( return OpenTelemetryVertxTracer.SpanOperation.span(context, requestSpan, headers, spanContext, scope); } + @Override + public void sendResponse( + final Context context, + final R response, + final OpenTelemetryVertxTracer.SpanOperation spanOperation, + final Throwable failure, + final TagExtractor tagExtractor) { + + HttpRouteHolder.updateHttpRoute(spanOperation.getSpanContext(), FILTER, RouteGetter.ROUTE_GETTER, + ((HttpRequestSpan) spanOperation.getRequest())); + InstrumenterVertxTracer.super.sendResponse(context, response, spanOperation, failure, tagExtractor); + } + @Override public HttpRequest writableHeaders( final HttpRequest request, final BiConsumer headers) { @@ -93,12 +105,13 @@ private static Instrumenter getServerInstrumenter(fin InstrumenterBuilder serverBuilder = Instrumenter.builder( openTelemetry, INSTRUMENTATION_NAME, - ServerSpanNameExtractor.create(serverAttributesExtractor)); + HttpSpanNameExtractor.create(serverAttributesExtractor)); return serverBuilder .setSpanStatusExtractor(HttpSpanStatusExtractor.create(serverAttributesExtractor)) .addAttributesExtractor(HttpServerAttributesExtractor.create(serverAttributesExtractor)) .addAttributesExtractor(new AdditionalServerAttributesExtractor()) + .addContextCustomizer(HttpRouteHolder.get()) .newServerInstrumenter(new HttpRequestTextMapGetter()); } @@ -117,6 +130,26 @@ private static Instrumenter getClientInstrumenter(fin .newClientInstrumenter(new HttpRequestTextMapSetter()); } + private static class RouteGetter implements HttpRouteGetter { + static final RouteGetter ROUTE_GETTER = new RouteGetter(); + + @Override + public String get(final io.opentelemetry.context.Context context, final HttpRequestSpan requestSpan) { + // RESTEasy + String route = requestSpan.getContext().getLocal("UrlPathTemplate"); + if (route == null) { + // Vert.x + route = requestSpan.getContext().getLocal("VertxRoute"); + } + + if (route != null && route.length() > 1) { + return route; + } + + return null; + } + } + private static class ServerAttributesExtractor implements HttpServerAttributesGetter { @Override public String flavor(final HttpRequest request) { @@ -213,37 +246,13 @@ private static Long getContentLength(final MultiMap headers) { } } - // TODO - Ideally this should use HttpSpanNameExtractor, but to keep the name without the slash we use our own. - private static class ServerSpanNameExtractor implements SpanNameExtractor { - private final HttpServerAttributesGetter serverAttributesExtractor; - - ServerSpanNameExtractor( - final HttpServerAttributesGetter serverAttributesExtractor) { - this.serverAttributesExtractor = serverAttributesExtractor; - } - - @Override - public String extract(final HttpRequest httpRequest) { - if (httpRequest instanceof HttpServerRequest) { - String path = URI.create(httpRequest.uri()).getPath(); - if (path != null && path.length() > 1) { - return path.substring(1); - } else { - return "HTTP " + httpRequest.method(); - } - } - return null; - } - - static SpanNameExtractor create( - HttpServerAttributesGetter serverAttributesExtractor) { - return new ServerSpanNameExtractor(serverAttributesExtractor); - } - } - private static class AdditionalServerAttributesExtractor implements AttributesExtractor { @Override - public void onStart(final AttributesBuilder attributes, final HttpRequest httpRequest) { + public void onStart( + final AttributesBuilder attributes, + final io.opentelemetry.context.Context parentContext, + final HttpRequest httpRequest) { + if (httpRequest instanceof HttpServerRequest) { set(attributes, HTTP_CLIENT_IP, VertxUtil.extractClientIP((HttpServerRequest) httpRequest)); } @@ -252,26 +261,11 @@ public void onStart(final AttributesBuilder attributes, final HttpRequest httpRe @Override public void onEnd( final AttributesBuilder attributes, + final io.opentelemetry.context.Context context, final HttpRequest httpRequest, final HttpResponse httpResponse, final Throwable error) { - // The UrlPathTemplate is only added to the Vert.x context after the instrumenter start - if (httpRequest instanceof HttpRequestSpan) { - HttpRequestSpan httpRequestSpan = (HttpRequestSpan) httpRequest; - // RESTEasy - String route = httpRequestSpan.getContext().getLocal("UrlPathTemplate"); - if (route == null) { - // Vert.x - route = httpRequestSpan.getContext().getLocal("VertxRoute"); - } - - if (route != null && route.length() > 1) { - set(attributes, HTTP_ROUTE, route); - Span span = Span.fromContext(httpRequestSpan.getSpanContext()); - span.updateName(route.substring(1)); - } - } } } diff --git a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveClientTest.java b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveClientTest.java index e197c8da71cb9..06f6e6a1acafc 100644 --- a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveClientTest.java +++ b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveClientTest.java @@ -64,7 +64,7 @@ void get() { assertEquals(SpanKind.SERVER.toString(), server.get("kind")); assertEquals(server.get("parentSpanId"), client.get("spanId")); - assertEquals("reactive", server.get("name")); + assertEquals("/reactive", server.get("name")); assertEquals("/reactive", ((Map) server.get("attributes")).get(HTTP_ROUTE.getKey())); assertEquals("/reactive?name=Naruto", ((Map) server.get("attributes")).get(HTTP_TARGET.getKey())); assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_STATUS_CODE.getKey())); @@ -100,7 +100,7 @@ void post() { assertEquals(SpanKind.SERVER.toString(), server.get("kind")); assertEquals(server.get("parentSpanId"), client.get("spanId")); - assertEquals("reactive", server.get("name")); + assertEquals("/reactive", server.get("name")); assertEquals("/reactive", ((Map) server.get("attributes")).get(HTTP_ROUTE.getKey())); assertEquals("/reactive", ((Map) server.get("attributes")).get(HTTP_TARGET.getKey())); assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_STATUS_CODE.getKey())); diff --git a/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/HelloRouterTest.java b/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/HelloRouterTest.java index b685d1c4f68c7..10e97fe7e7974 100644 --- a/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/HelloRouterTest.java +++ b/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/HelloRouterTest.java @@ -55,7 +55,7 @@ void span() { assertEquals(1, spans.size()); assertEquals(SERVER.toString(), spans.get(0).get("kind")); - assertEquals("hello", spans.get(0).get("name")); + assertEquals("/hello", spans.get(0).get("name")); assertEquals(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_STATUS_CODE.toString())); assertEquals(HttpMethod.GET.toString(), ((Map) spans.get(0).get("attributes")).get(HTTP_METHOD.toString())); assertEquals("/hello", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); @@ -74,7 +74,7 @@ void spanPath() { assertEquals(1, spans.size()); assertEquals(SERVER.toString(), spans.get(0).get("kind")); - assertEquals("hello/:name", spans.get(0).get("name")); + assertEquals("/hello/:name", spans.get(0).get("name")); assertEquals(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_STATUS_CODE.toString())); assertEquals(HttpMethod.GET.toString(), ((Map) spans.get(0).get("attributes")).get(HTTP_METHOD.toString())); assertEquals("/hello/:name", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); @@ -95,7 +95,7 @@ void post() { assertEquals(1, spans.size()); assertEquals(SERVER.toString(), spans.get(0).get("kind")); - assertEquals("hello", spans.get(0).get("name")); + assertEquals("/hello", spans.get(0).get("name")); assertEquals(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_STATUS_CODE.toString())); assertEquals(HttpMethod.POST.toString(), ((Map) spans.get(0).get("attributes")).get(HTTP_METHOD.toString())); assertEquals("/hello", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); @@ -137,7 +137,7 @@ void bus() { assertEquals("bus", ((Map) spans.get(1).get("attributes")).get(MESSAGING_DESTINATION.toString())); assertEquals(SERVER.toString(), spans.get(2).get("kind")); - assertEquals("bus", spans.get(2).get("name")); + assertEquals("/bus", spans.get(2).get("name")); assertEquals(HTTP_OK, ((Map) spans.get(2).get("attributes")).get(HTTP_STATUS_CODE.toString())); assertEquals(HttpMethod.GET.toString(), ((Map) spans.get(2).get("attributes")).get(HTTP_METHOD.toString())); assertEquals("/bus", ((Map) spans.get(2).get("attributes")).get(HTTP_ROUTE.toString())); diff --git a/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/SqlClientTest.java b/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/SqlClientTest.java index f0fd97872e01c..11c8dc7434036 100644 --- a/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/SqlClientTest.java +++ b/integration-tests/opentelemetry-vertx/src/test/java/io/quarkus/it/opentelemetry/vertx/SqlClientTest.java @@ -92,7 +92,7 @@ void sqlClient() { assertEquals(spans.get(0).getTraceId(), spans.get(1).getTraceId()); assertEquals(spans.get(0).getSpanId(), spans.get(1).getParentSpanId()); - assertEquals("sqlClient", spans.get(0).getName()); + assertEquals("/sqlClient", spans.get(0).getName()); assertEquals(HTTP_OK, spans.get(0).getAttributes().get(HTTP_STATUS_CODE)); assertEquals("SELECT USERS", spans.get(1).getName()); diff --git a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java index 773743fedbffa..42bd1fcddfd28 100644 --- a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java +++ b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java @@ -70,7 +70,7 @@ void testResourceTracing() { verifyResource(spanData); - Assertions.assertEquals("direct", spanData.get("name")); + Assertions.assertEquals("/direct", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -115,7 +115,7 @@ void testEmptyClientPath() { Assertions.assertNotNull(spanData.get("spanId")); if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("nopath")) { + && spanData.get("name").equals("/nopath")) { outsideServerFound = true; // Server Span serverSpanId = (String) spanData.get("spanId"); @@ -123,7 +123,7 @@ void testEmptyClientPath() { verifyResource(spanData); - Assertions.assertEquals("nopath", spanData.get("name")); + Assertions.assertEquals("/nopath", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -229,7 +229,7 @@ void testSlashClientPath() { Assertions.assertNotNull(spanData.get("spanId")); if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("slashpath")) { + && spanData.get("name").equals("/slashpath")) { outsideServerFound = true; // Server Span serverSpanId = (String) spanData.get("spanId"); @@ -237,7 +237,7 @@ void testSlashClientPath() { verifyResource(spanData); - Assertions.assertEquals("slashpath", spanData.get("name")); + Assertions.assertEquals("/slashpath", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -335,7 +335,7 @@ void testChainedResourceTracing() { verifyResource(spanData); - Assertions.assertEquals("chained", spanData.get("name")); + Assertions.assertEquals("/chained", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -392,7 +392,7 @@ void testTracingWithParentHeaders() { verifyResource(spanData); - Assertions.assertEquals("direct", spanData.get("name")); + Assertions.assertEquals("/direct", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -429,7 +429,7 @@ void testDeepPathNaming() { verifyResource(spanData); - Assertions.assertEquals("deep/path", spanData.get("name")); + Assertions.assertEquals("/deep/path", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -466,7 +466,7 @@ void testPathParameter() { verifyResource(spanData); - Assertions.assertEquals("param/{paramId}", spanData.get("name")); + Assertions.assertEquals("/param/{paramId}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -511,7 +511,7 @@ void testClientTracing() { Assertions.assertNotNull(spanData.get("spanId")); if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("client/ping/{message}")) { + && spanData.get("name").equals("/client/ping/{message}")) { outsideServerFound = true; // Server Span serverSpanId = (String) spanData.get("spanId"); @@ -519,7 +519,7 @@ void testClientTracing() { verifyResource(spanData); - Assertions.assertEquals("client/ping/{message}", spanData.get("name")); + Assertions.assertEquals("/client/ping/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -538,12 +538,12 @@ void testClientTracing() { Assertions.assertNotNull(spanData.get("attr_http.client_ip")); Assertions.assertNotNull(spanData.get("attr_http.user_agent")); } else if (spanData.get("kind").equals(SpanKind.CLIENT.toString()) - && spanData.get("name").equals("client/pong/{message}")) { + && spanData.get("name").equals("/client/pong/{message}")) { clientFound = true; // Client span verifyResource(spanData); - Assertions.assertEquals("client/pong/{message}", spanData.get("name")); + Assertions.assertEquals("/client/pong/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.CLIENT.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -562,12 +562,12 @@ void testClientTracing() { clientSpanId = (String) spanData.get("spanId"); } else if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("client/pong/{message}")) { + && spanData.get("name").equals("/client/pong/{message}")) { clientServerFound = true; // Server span of client verifyResource(spanData); - Assertions.assertEquals("client/pong/{message}", spanData.get("name")); + Assertions.assertEquals("/client/pong/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -624,7 +624,7 @@ void testAsyncClientTracing() { Assertions.assertNotNull(spanData.get("spanId")); if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("client/async-ping/{message}")) { + && spanData.get("name").equals("/client/async-ping/{message}")) { outsideServerFound = true; // Server Span serverSpanId = (String) spanData.get("spanId"); @@ -632,7 +632,7 @@ void testAsyncClientTracing() { verifyResource(spanData); - Assertions.assertEquals("client/async-ping/{message}", spanData.get("name")); + Assertions.assertEquals("/client/async-ping/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -651,12 +651,12 @@ void testAsyncClientTracing() { Assertions.assertNotNull(spanData.get("attr_http.client_ip")); Assertions.assertNotNull(spanData.get("attr_http.user_agent")); } else if (spanData.get("kind").equals(SpanKind.CLIENT.toString()) - && spanData.get("name").equals("client/pong/{message}")) { + && spanData.get("name").equals("/client/pong/{message}")) { clientFound = true; // Client span verifyResource(spanData); - Assertions.assertEquals("client/pong/{message}", spanData.get("name")); + Assertions.assertEquals("/client/pong/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.CLIENT.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -675,12 +675,12 @@ void testAsyncClientTracing() { clientSpanId = (String) spanData.get("spanId"); } else if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("client/pong/{message}")) { + && spanData.get("name").equals("/client/pong/{message}")) { clientServerFound = true; // Server span of client verifyResource(spanData); - Assertions.assertEquals("client/pong/{message}", spanData.get("name")); + Assertions.assertEquals("/client/pong/{message}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -730,7 +730,7 @@ void testTemplatedPathOnClass() { verifyResource(spanData); - Assertions.assertEquals("template/path/{value}", spanData.get("name")); + Assertions.assertEquals("/template/path/{value}", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); diff --git a/integration-tests/rest-client-reactive/src/test/java/io/quarkus/it/rest/client/BasicTest.java b/integration-tests/rest-client-reactive/src/test/java/io/quarkus/it/rest/client/BasicTest.java index 52e452a7e3ef6..bad0eab912763 100644 --- a/integration-tests/rest-client-reactive/src/test/java/io/quarkus/it/rest/client/BasicTest.java +++ b/integration-tests/rest-client-reactive/src/test/java/io/quarkus/it/rest/client/BasicTest.java @@ -131,13 +131,13 @@ void shouldCreateClientSpans() { Assertions.assertNotNull(spanData.get("spanId")); if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("call-hello-client")) { + && spanData.get("name").equals("/call-hello-client")) { outsideServerFound = true; // Server Span serverSpanId = (String) spanData.get("spanId"); serverTraceId = (String) spanData.get("traceId"); - Assertions.assertEquals("call-hello-client", spanData.get("name")); + Assertions.assertEquals("/call-hello-client", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended")); @@ -181,11 +181,11 @@ void shouldCreateClientSpans() { clientSpanId = (String) spanData.get("spanId"); } else if (spanData.get("kind").equals(SpanKind.SERVER.toString()) - && spanData.get("name").equals("hello")) { + && spanData.get("name").equals("/hello")) { clientServerFound = true; // Server span of client - Assertions.assertEquals("hello", spanData.get("name")); + Assertions.assertEquals("/hello", spanData.get("name")); Assertions.assertEquals(SpanKind.SERVER.toString(), spanData.get("kind")); Assertions.assertTrue((Boolean) spanData.get("ended"));