diff --git a/src/main/java/io/vertx/core/eventbus/impl/MessageTagExtractor.java b/src/main/java/io/vertx/core/eventbus/impl/MessageTagExtractor.java index d762b6ff990..a11a7e72312 100644 --- a/src/main/java/io/vertx/core/eventbus/impl/MessageTagExtractor.java +++ b/src/main/java/io/vertx/core/eventbus/impl/MessageTagExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -27,21 +27,31 @@ private MessageTagExtractor() { @Override public int len(Message obj) { - return 1; + return 3; } @Override public String name(Message obj, int index) { - if (index == 0) { - return "message_bus.destination"; + switch (index) { + case 0: + return "message_bus.destination"; + case 1: + return "message_bus.system"; + case 2: + return "message_bus.operation"; } throw new IndexOutOfBoundsException("Invalid tag index " + index); } @Override public String value(Message obj, int index) { - if (index == 0) { - return obj.address(); + switch (index) { + case 0: + return obj.address(); + case 1: + return "vertx-eventbus"; + case 2: + return "publish"; } throw new IndexOutOfBoundsException("Invalid tag index " + index); } diff --git a/src/main/java/io/vertx/core/http/impl/HttpUtils.java b/src/main/java/io/vertx/core/http/impl/HttpUtils.java index d6978e88419..38f1d2e4e98 100644 --- a/src/main/java/io/vertx/core/http/impl/HttpUtils.java +++ b/src/main/java/io/vertx/core/http/impl/HttpUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -69,7 +69,7 @@ public final class HttpUtils { static final TagExtractor SERVER_REQUEST_TAG_EXTRACTOR = new TagExtractor() { @Override public int len(HttpServerRequest req) { - return 2; + return req.query() == null ? 4 : 5; } @Override public String name(HttpServerRequest req, int index) { @@ -78,6 +78,12 @@ public String name(HttpServerRequest req, int index) { return "http.url"; case 1: return "http.method"; + case 2: + return "http.scheme"; + case 3: + return "http.path"; + case 4: + return "http.query"; } throw new IndexOutOfBoundsException("Invalid tag index " + index); } @@ -88,6 +94,12 @@ public String value(HttpServerRequest req, int index) { return req.absoluteURI(); case 1: return req.method().name(); + case 2: + return req.scheme(); + case 3: + return req.path(); + case 4: + return req.query(); } throw new IndexOutOfBoundsException("Invalid tag index " + index); } diff --git a/src/test/java/io/vertx/core/spi/tracing/EventBusTracingTestBase.java b/src/test/java/io/vertx/core/spi/tracing/EventBusTracingTestBase.java index d377bba61bb..84074f624c0 100644 --- a/src/test/java/io/vertx/core/spi/tracing/EventBusTracingTestBase.java +++ b/src/test/java/io/vertx/core/spi/tracing/EventBusTracingTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation + * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -14,7 +14,6 @@ import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.core.tracing.TracingPolicy; -import io.vertx.test.core.Repeat; import io.vertx.test.core.VertxTestBase; import io.vertx.test.faketracer.FakeTracer; import io.vertx.test.faketracer.Span; @@ -170,6 +169,8 @@ private void testRequestReply(TracingPolicy policy, boolean create, boolean fail assertSingleTrace(finishedSpans); finishedSpans.forEach(span -> { assertEquals("send", span.operation); + assertEquals("vertx-eventbus", span.getTags().get("message_bus.system")); + assertEquals("publish", span.getTags().get("message_bus.operation")); }); } diff --git a/src/test/java/io/vertx/core/spi/tracing/HttpTracingTestBase.java b/src/test/java/io/vertx/core/spi/tracing/HttpTracingTestBase.java index a5711788425..31c7ac522d9 100644 --- a/src/test/java/io/vertx/core/spi/tracing/HttpTracingTestBase.java +++ b/src/test/java/io/vertx/core/spi/tracing/HttpTracingTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation + * Copyright (c) 2011-2023 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -11,9 +11,12 @@ package io.vertx.core.spi.tracing; import io.vertx.core.Context; -import io.vertx.core.http.*; -import io.vertx.test.faketracer.Span; +import io.vertx.core.http.HttpClientRequest; +import io.vertx.core.http.HttpClientResponse; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpTestBase; import io.vertx.test.faketracer.FakeTracer; +import io.vertx.test.faketracer.Span; import org.junit.Test; import java.util.List; @@ -108,7 +111,7 @@ public void testMultipleHttpServerRequest() throws Exception { switch (serverReq.path()) { case "/1": { vertx.setTimer(10, id -> { - client.request(HttpMethod.GET, 8080, "localhost", "/2") + client.request(HttpMethod.GET, 8080, "localhost", "/2?q=true") .compose(HttpClientRequest::send) .onComplete(onSuccess(resp -> { serverReq.response().end(); @@ -156,9 +159,12 @@ public void testMultipleHttpServerRequest() throws Exception { String scheme = createBaseServerOptions().isSsl() ? "https" : "http"; for (Span server2Span: lastServerSpans) { + assertEquals(scheme, server2Span.getTags().get("http.scheme")); + assertEquals("/2", server2Span.getTags().get("http.path")); + assertEquals("q=true", server2Span.getTags().get("http.query")); Span client2Span = spanMap.get(server2Span.parentId); assertEquals("GET", client2Span.operation); - assertEquals(scheme + "://localhost:8080/2", client2Span.getTags().get("http.url")); + assertEquals(scheme + "://localhost:8080/2?q=true", client2Span.getTags().get("http.url")); assertEquals("200", client2Span.getTags().get("http.status_code")); assertEquals("client", client2Span.getTags().get("span_kind")); Span server1Span = spanMap.get(client2Span.parentId);