diff --git a/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/SimpleResource.java b/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/SimpleResource.java index 5abc30290a4109..dcb38b74ea92a0 100644 --- a/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/SimpleResource.java +++ b/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/SimpleResource.java @@ -17,6 +17,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.Meter; import io.opentelemetry.context.Scope; +import io.quarkus.opentelemetry.runtime.tracing.Traceless; @Path("") @Produces(MediaType.APPLICATION_JSON) @@ -150,4 +151,21 @@ public String exception() { LOG.error("Oh no {}", exception.getMessage(), exception); return "Oh no! An exception"; } + + @GET + @Path("/suppress-app-uri") + public TraceData suppressAppUri() { + TraceData traceData = new TraceData(); + traceData.message = "Suppress me!"; + return traceData; + } + + @GET + @Path("/traceless") + @Traceless + public TraceData traceless() { + TraceData traceData = new TraceData(); + traceData.message = "@Traceless"; + return traceData; + } } diff --git a/integration-tests/opentelemetry/src/main/resources/application.properties b/integration-tests/opentelemetry/src/main/resources/application.properties index 3df96e1b77b035..25541a9d29c7c0 100644 --- a/integration-tests/opentelemetry/src/main/resources/application.properties +++ b/integration-tests/opentelemetry/src/main/resources/application.properties @@ -20,3 +20,6 @@ quarkus.security.users.embedded.users.scott=reader quarkus.security.users.embedded.plain-text=true quarkus.security.users.embedded.enabled=true quarkus.http.auth.basic=true + + +quarkus.otel.traces.suppress-application-uris=/suppress-app-uri \ No newline at end of file diff --git a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/TracingTest.java b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/TracingTest.java index 43b8b52daa1b4a..fdad57689c703c 100644 --- a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/TracingTest.java +++ b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/TracingTest.java @@ -12,12 +12,7 @@ import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.net.URI; @@ -27,6 +22,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; +import org.awaitility.core.ConditionTimeoutException; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -58,6 +54,8 @@ public class TracingTest { URL deepPathUrl; @TestHTTPResource("param") URL pathParamUrl; + @TestHTTPResource + URL suppressAppUrl; @BeforeEach @AfterEach @@ -743,6 +741,34 @@ public void testNoEndUserAttributes() { .findAny().isEmpty()); } + @Test + public void testSuppressAppUri() { + RestAssured.given() + .when().get("/suppress-app-uri") + .then() + .statusCode(200) + .body("message", Matchers.is("Suppress me!")); + + // should throw because there are a configuration quarkus.otel.traces.suppress-app-uris=/suppress-app-uri + assertThrows(ConditionTimeoutException.class, () -> { + await().atMost(5, SECONDS).until(() -> !getSpans().isEmpty()); + }); + } + + @Test + public void testTracelessResource() { + RestAssured.given() + .when().get("/traceless") + .then() + .statusCode(200) + .body("message", Matchers.is("@Traceless")); + + // should throw because there is no span + assertThrows(ConditionTimeoutException.class, () -> { + await().atMost(5, SECONDS).until(() -> !getSpans().isEmpty()); + }); + } + private void verifyResource(Map spanData) { assertEquals("opentelemetry-integration-test", spanData.get("resource_service.name")); assertEquals("999-SNAPSHOT", spanData.get("resource_service.version"));