diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 2f692902539cd..90565c80ac430 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -31,9 +31,9 @@ 0.2.4 0.1.15 0.1.5 - 1.32.0 - 1.32.0-alpha - 1.21.0-alpha + 1.39.0 + 2.5.0-alpha + 1.25.0-alpha 5.3.0 1.12.5 2.1.12 @@ -62,7 +62,7 @@ 1.0.13 3.0.1 3.13.2 - 4.22.0 + 4.23.0 2.6.0 2.1.3 3.0.0 @@ -393,7 +393,7 @@ io.opentelemetry opentelemetry-bom-alpha - ${opentelemetry-alpha.version} + ${opentelemetry.version}-alpha pom import diff --git a/extensions/opentelemetry/deployment/pom.xml b/extensions/opentelemetry/deployment/pom.xml index 6bdba442a7377..edf033a78999f 100644 --- a/extensions/opentelemetry/deployment/pom.xml +++ b/extensions/opentelemetry/deployment/pom.xml @@ -152,38 +152,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - new-http-semconv - - test - - - - http - - - - - http-dup-semconv - - test - - - - http/dup - - - - - - org.xolstice.maven.plugins protobuf-maven-plugin diff --git a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java index 4664cb0d67faf..2fff029e4344e 100644 --- a/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java +++ b/extensions/opentelemetry/deployment/src/main/java/io/quarkus/opentelemetry/deployment/OpenTelemetryProcessor.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.function.Predicate; @@ -17,7 +16,6 @@ import org.eclipse.microprofile.config.ConfigValue; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; -import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.ClassType; import org.jboss.jandex.DotName; import org.jboss.jandex.MethodInfo; @@ -44,7 +42,6 @@ import io.quarkus.arc.deployment.InterceptorBindingRegistrarBuildItem; import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.arc.deployment.ValidationPhaseBuildItem.ValidationErrorBuildItem; -import io.quarkus.arc.processor.AnnotationsTransformer; import io.quarkus.arc.processor.InterceptorBindingRegistrar; import io.quarkus.arc.processor.Transformation; import io.quarkus.datasource.common.runtime.DataSourceUtil; @@ -81,8 +78,6 @@ @BuildSteps(onlyIf = OpenTelemetryEnabled.class) public class OpenTelemetryProcessor { - private static final DotName LEGACY_WITH_SPAN = DotName.createSimple( - io.opentelemetry.extension.annotations.WithSpan.class.getName()); private static final DotName WITH_SPAN = DotName.createSimple(WithSpan.class.getName()); private static final DotName ADD_SPAN_ATTRIBUTES = DotName.createSimple(AddingSpanAttributes.class.getName()); private static final Predicate isAddSpanAttribute = new Predicate<>() { @@ -95,8 +90,6 @@ public boolean test(AnnotationInstance annotationInstance) { private static final DotName WITH_SPAN_INTERCEPTOR = DotName.createSimple(WithSpanInterceptor.class.getName()); private static final DotName ADD_SPAN_ATTRIBUTES_INTERCEPTOR = DotName .createSimple(AddingSpanAttributesInterceptor.class.getName()); - private static final String QUARKUS_OTEL_SEMCONV_STABILITY_OPT_IN = "quarkus.otel.semconv-stability.opt-in"; - private static final String OTEL_SEMCONV_STABILITY_OPT_IN = "otel.semconv-stability.opt-in"; @BuildStep AdditionalBeanBuildItem ensureProducerIsRetained() { @@ -114,15 +107,6 @@ AdditionalBeanBuildItem ensureProducerIsRetained() { @BuildStep @Record(ExecutionTime.RUNTIME_INIT) SyntheticBeanBuildItem openTelemetryBean(OpenTelemetryRecorder recorder, OTelRuntimeConfig oTelRuntimeConfig) { - - final String semconvStability = ConfigProvider.getConfig() - .getConfigValue(QUARKUS_OTEL_SEMCONV_STABILITY_OPT_IN) - .getValue(); - if (semconvStability != null && !semconvStability.isEmpty()) { - // yes, they ignore config supplier on this. - System.setProperty(OTEL_SEMCONV_STABILITY_OPT_IN, semconvStability); - } - return SyntheticBeanBuildItem.configure(OpenTelemetry.class) .defaultBean() .setRuntimeInit() @@ -229,35 +213,6 @@ public List getAdditionalBindings() { @BuildStep void transformWithSpan(BuildProducer annotationsTransformer) { - // Transform deprecated annotation into new one - annotationsTransformer.produce(new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { - @Override - public boolean appliesTo(AnnotationTarget.Kind kind) { - return kind == AnnotationTarget.Kind.METHOD; - } - - @Override - public void transform(TransformationContext context) { - final AnnotationTarget target = context.getTarget(); - - List legacyWithSpans = context.getAnnotations().stream() - .filter(annotationInstance -> annotationInstance.name().equals(LEGACY_WITH_SPAN)) - .collect(toList()); - - for (AnnotationInstance legacyAnnotation : legacyWithSpans) { - AnnotationValue value = Optional.ofNullable(legacyAnnotation.value("value")) - .orElse(AnnotationValue.createStringValue("value", "")); - AnnotationValue kind = Optional.ofNullable(legacyAnnotation.value("kind")) - .orElse(AnnotationValue.createEnumValue("kind", SPAN_KIND, SpanKind.INTERNAL.name())); - AnnotationInstance annotation = AnnotationInstance.create( - WITH_SPAN, - target, - List.of(value, kind)); - context.transform().add(annotation).done(); - } - } - })); - annotationsTransformer.produce(new AnnotationsTransformerBuildItem(transformationContext -> { AnnotationTarget target = transformationContext.getTarget(); Transformation transform = transformationContext.transform(); @@ -306,10 +261,7 @@ void setupVertx(InstrumentationRecorder recorder, BeanContainerBuildItem beanCon boolean redisClientAvailable = capabilities.isPresent(Capability.REDIS_CLIENT); recorder.setupVertxTracer(beanContainerBuildItem.getValue(), sqlClientAvailable, - redisClientAvailable, - ConfigProvider.getConfig() - .getConfigValue(QUARKUS_OTEL_SEMCONV_STABILITY_OPT_IN) - .getValue()); + redisClientAvailable); } @BuildStep diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/InMemoryMetricExporter.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/InMemoryMetricExporter.java index 59bd8aa6f4399..8036cd087add8 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/InMemoryMetricExporter.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/InMemoryMetricExporter.java @@ -21,7 +21,6 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.metrics.InstrumentType; import io.opentelemetry.sdk.metrics.data.AggregationTemporality; @@ -35,9 +34,6 @@ @ApplicationScoped public class InMemoryMetricExporter implements MetricExporter { - private static final List LEGACY_KEY_COMPONENTS = List.of(SemanticAttributes.HTTP_METHOD.getKey(), - SemanticAttributes.HTTP_ROUTE.getKey(), - SemanticAttributes.HTTP_STATUS_CODE.getKey()); private static final List KEY_COMPONENTS = List.of(SemanticAttributes.HTTP_REQUEST_METHOD.getKey(), SemanticAttributes.HTTP_ROUTE.getKey(), SemanticAttributes.HTTP_RESPONSE_STATUS_CODE.getKey()); @@ -77,13 +73,7 @@ public static Map getMostRecentPointsMap(List fin .collect(toMap( pointData -> pointData.getAttributes().asMap().entrySet().stream() //valid attributes for the resulting map key - .filter(entry -> { - if (SemconvStability.emitOldHttpSemconv()) { - return LEGACY_KEY_COMPONENTS.contains(entry.getKey().getKey()); - } else { - return KEY_COMPONENTS.contains(entry.getKey().getKey()); - } - }) + .filter(entry -> KEY_COMPONENTS.contains(entry.getKey().getKey())) // ensure order .sorted(Comparator.comparing(o -> o.getKey().getKey())) // build key diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/SemconvResolver.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/SemconvResolver.java index ca6f18bc99d49..de74e3ee96bab 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/SemconvResolver.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/SemconvResolver.java @@ -2,137 +2,39 @@ import static io.opentelemetry.api.common.AttributeType.LONG; import static io.opentelemetry.api.common.AttributeType.STRING; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_TARGET; -import static io.opentelemetry.semconv.SemanticAttributes.URL_PATH; -import static io.opentelemetry.semconv.SemanticAttributes.URL_QUERY; -import static io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType.HTTP; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; +import static io.opentelemetry.semconv.UrlAttributes.URL_QUERY; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.util.HashMap; -import java.util.Map; - -import org.jboss.logging.Logger; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.sdk.trace.data.SpanData; -import io.quarkus.opentelemetry.runtime.OpenTelemetryUtil; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; public class SemconvResolver { - public static final SemconvStabilityType SEMCONV_STABILITY_TYPE; - private static final Map conventionsMapper = new HashMap<>(); - private static final Logger log = Logger.getLogger(SemconvResolver.class); - - static { - SEMCONV_STABILITY_TYPE = OpenTelemetryUtil.getSemconvStabilityOptin( - System.getProperty("quarkus.otel.semconv-stability.opt-in", "stable")); - - log.info("Using semantic convention stability type: " + SEMCONV_STABILITY_TYPE); - - conventionsMapper.put("http.method", "http.request.method"); - conventionsMapper.put("http.status_code", "http.response.status_code"); - conventionsMapper.put("http.request_content_length", "http.request.body.size"); - conventionsMapper.put("http.response_content_length", "http.request.body.size"); - conventionsMapper.put("net.protocol.name", "network.protocol.name"); - conventionsMapper.put("net.protocol.version", "network.protocol.version"); - // net.sock.family removed - conventionsMapper.put("net.sock.peer.addr", "network.peer.address"); - conventionsMapper.put("net.sock.peer.port", "network.peer.port"); - // net.sock.peer.name removed - // New: http.request.method_original - // New: error.type - conventionsMapper.put("http.url", "url.full"); - conventionsMapper.put("http.resend_count", "http.request.resend_count"); - conventionsMapper.put("net.peer.name", "server.address"); - conventionsMapper.put("net.peer.port", "server.port"); - // http.target split into url.path and url.query - conventionsMapper.put("http.scheme", "url.scheme"); - conventionsMapper.put("http.client_ip", "client.address"); - conventionsMapper.put("net.host.name", "server.address"); - conventionsMapper.put("net.host.port", "server.port"); - - } - SemconvResolver() { // empty } public static void assertTarget(final SpanData server, final String path, final String query) { - switch (SEMCONV_STABILITY_TYPE) { - case HTTP: - assertEquals(path, server.getAttributes().get(URL_PATH)); - assertEquals(query, server.getAttributes().get(URL_QUERY)); - break; - case HTTP_DUP: - assertEquals(path, server.getAttributes().get(URL_PATH)); - assertEquals(query, server.getAttributes().get(URL_QUERY)); - assertEquals("" + path + (query == null ? "" : "?" + query), server.getAttributes().get(HTTP_TARGET)); - break; - case HTTP_OLD: - assertEquals("" + path + (query == null ? "" : "?" + query), server.getAttributes().get(HTTP_TARGET)); - break; - default: - throw new IllegalArgumentException("Unsupported semantic convention stability type: " + SEMCONV_STABILITY_TYPE); - } + assertEquals(path, server.getAttributes().get(URL_PATH)); + assertEquals(query, server.getAttributes().get(URL_QUERY)); } public static void assertSemanticAttribute(final SpanData spanData, final T expected, - final AttributeKey attribute) { - switch (SEMCONV_STABILITY_TYPE) { - case HTTP: - assertEquals(expected, getNewAttribute(spanData, attribute)); - break; - case HTTP_DUP: - assertEquals(expected, getNewAttribute(spanData, attribute)); // assert new semantic convention - assertEquals(expected, spanData.getAttributes().get(attribute)); // assert old semantic convention - break; - case HTTP_OLD: - assertEquals(expected, spanData.getAttributes().get(attribute)); // assert old semantic convention - break; - default: - throw new IllegalArgumentException("Unsupported semantic convention stability type: " + SEMCONV_STABILITY_TYPE); - } - } - - public static void assertNotNullSemanticAttribute(final SpanData spanData, - final AttributeKey attribute) { - switch (SemconvResolver.SEMCONV_STABILITY_TYPE) { - case HTTP: - assertNotNull(getNewAttribute(spanData, attribute)); - break; - case HTTP_DUP: - assertNotNull(getNewAttribute(spanData, attribute)); // assert new semantic convention - assertNotNull(spanData.getAttributes().get(attribute)); // assert old semantic convention - break; - case HTTP_OLD: - assertNotNull(spanData.getAttributes().get(attribute)); // assert old semantic convention - break; - default: - throw new IllegalArgumentException( - "Unsupported semantic convention stability type: " + SemconvResolver.SEMCONV_STABILITY_TYPE); - } + final AttributeKey attributeKey) { + assertEquals(expected, getAttribute(spanData, attributeKey)); } @SuppressWarnings("unchecked") - private static T getNewAttribute(final SpanData data, final AttributeKey legacyAttributeKey) { - if (legacyAttributeKey.getType().equals(LONG)) { - return (T) data.getAttributes().get(resolveLong((AttributeKey) legacyAttributeKey)); - } else if (legacyAttributeKey.getType().equals(STRING)) { - return (T) data.getAttributes().get(resolveString((AttributeKey) legacyAttributeKey)); + private static T getAttribute(final SpanData data, final AttributeKey attributeKey) { + if (attributeKey.getType().equals(LONG)) { + return (T) data.getAttributes().get(attributeKey); + } else if (attributeKey.getType().equals(STRING)) { + return (T) data.getAttributes().get(attributeKey); } else { throw new IllegalArgumentException( - "Unsupported attribute: " + legacyAttributeKey.getKey() + - " with type: " + legacyAttributeKey.getKey().getClass()); + "Unsupported attribute: " + attributeKey.getKey() + + " with type: " + attributeKey.getKey().getClass()); } } - - private static AttributeKey resolveString(final AttributeKey legacyKey) { - return AttributeKey.stringKey(conventionsMapper.get(legacyKey.getKey())); - } - - private static AttributeKey resolveLong(final AttributeKey legacyKey) { - return AttributeKey.longKey(conventionsMapper.get(legacyKey.getKey())); - } } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GraphQLOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GraphQLOpenTelemetryTest.java index 293e5279f2fb3..208fa62f82952 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GraphQLOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GraphQLOpenTelemetryTest.java @@ -1,9 +1,9 @@ package io.quarkus.opentelemetry.deployment.instrumentation; import static io.opentelemetry.api.common.AttributeKey.stringKey; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; import static java.net.HttpURLConnection.HTTP_OK; @@ -282,8 +282,8 @@ private void assertTimeForSpans(List spans) { private SpanData assertHttpSpan(List spans) { final SpanData server = getSpanByKindAndParentId(spans, SpanKind.SERVER, "0000000000000000"); assertEquals("POST /graphql", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, "POST", HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, "POST", HTTP_REQUEST_METHOD); assertEquals("/graphql", server.getAttributes().get(HTTP_ROUTE)); return server; } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GrpcOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GrpcOpenTelemetryTest.java index f2fc2c2c62638..89371d8692ff4 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GrpcOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/GrpcOpenTelemetryTest.java @@ -4,17 +4,17 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.INTERNAL; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_PORT; import static io.opentelemetry.semconv.SemanticAttributes.RPC_GRPC_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.RPC_METHOD; import static io.opentelemetry.semconv.SemanticAttributes.RPC_SERVICE; import static io.opentelemetry.semconv.SemanticAttributes.RPC_SYSTEM; -import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertNotNullSemanticAttribute; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; import static io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig.INSTRUMENTATION_NAME; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -130,8 +130,8 @@ void grpc() { assertEquals("helloworld.Greeter", server.getAttributes().get(RPC_SERVICE)); assertEquals("SayHello", server.getAttributes().get(RPC_METHOD)); assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE)); - assertNotNullSemanticAttribute(server, NET_HOST_PORT); - assertNotNullSemanticAttribute(server, NET_HOST_NAME); + assertNotNull(server.getAttributes().get(SERVER_PORT)); + assertNotNull(server.getAttributes().get(SERVER_ADDRESS)); final SpanData internal = getSpanByKindAndParentId(spans, INTERNAL, server.getSpanId()); assertEquals("span.internal", internal.getName()); @@ -168,8 +168,8 @@ void error() { assertEquals("helloworld.Greeter", server.getAttributes().get(RPC_SERVICE)); assertEquals("SayHello", server.getAttributes().get(RPC_METHOD)); assertEquals(Status.Code.UNKNOWN.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE)); - assertNotNullSemanticAttribute(server, NET_HOST_PORT); - assertNotNullSemanticAttribute(server, NET_HOST_NAME); + assertNotNull(server.getAttributes().get(SERVER_PORT)); + assertNotNull(server.getAttributes().get(SERVER_ADDRESS)); assertEquals(Status.Code.UNKNOWN.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE)); assertEquals(server.getTraceId(), client.getTraceId()); @@ -219,8 +219,8 @@ void streaming() { assertEquals("streaming.Streaming", server.getAttributes().get(RPC_SERVICE)); assertEquals("Pipe", server.getAttributes().get(RPC_METHOD)); assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE)); - assertNotNullSemanticAttribute(server, NET_HOST_PORT); - assertNotNullSemanticAttribute(server, NET_HOST_NAME); + assertNotNull(server.getAttributes().get(SERVER_PORT)); + assertNotNull(server.getAttributes().get(SERVER_ADDRESS)); assertEquals("true", server.getAttributes().get(stringKey("grpc.service.propagated"))); assertEquals(server.getTraceId(), client.getTraceId()); @@ -255,8 +255,8 @@ void streamingBlocking() { assertEquals("streaming.Streaming", server.getAttributes().get(RPC_SERVICE)); assertEquals("PipeBlocking", server.getAttributes().get(RPC_METHOD)); assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE)); - assertNotNullSemanticAttribute(server, NET_HOST_PORT); - assertNotNullSemanticAttribute(server, NET_HOST_NAME); + assertNotNull(server.getAttributes().get(SERVER_PORT)); + assertNotNull(server.getAttributes().get(SERVER_ADDRESS)); assertEquals("true", server.getAttributes().get(stringKey("grpc.service.propagated.blocking"))); assertEquals(server.getTraceId(), client.getTraceId()); diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/RestClientOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/RestClientOpenTelemetryTest.java index d0ecccaa1dd57..2c42cb42e89d8 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/RestClientOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/RestClientOpenTelemetryTest.java @@ -2,12 +2,12 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_URL; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_PORT; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; +import static io.opentelemetry.semconv.UrlAttributes.URL_FULL; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertTarget; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; @@ -77,17 +77,17 @@ void client() { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals("GET /hello", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello", HTTP_URL); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello", URL_FULL); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals("GET /hello", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, HttpMethod.GET, HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, HttpMethod.GET, HTTP_REQUEST_METHOD); assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(server, uri.getHost(), NET_HOST_NAME); - assertSemanticAttribute(server, (long) uri.getPort(), NET_HOST_PORT); + assertSemanticAttribute(server, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(server, (long) uri.getPort(), SERVER_PORT); assertTarget(server, uri.getPath() + "hello", null); assertEquals(client.getTraceId(), server.getTraceId()); @@ -102,9 +102,9 @@ void spanNameWithoutQueryString() { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(CLIENT, client.getKind()); assertEquals("GET /hello", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello?query=1", HTTP_URL); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello?query=1", URL_FULL); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(client.getTraceId(), server.getTraceId()); @@ -121,9 +121,9 @@ void urlWithoutAuthentication() { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(CLIENT, client.getKind()); assertEquals("GET", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello?query=1", HTTP_URL); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello?query=1", URL_FULL); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(client.getTraceId(), server.getTraceId()); @@ -138,18 +138,18 @@ void path() { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(CLIENT, client.getKind()); assertEquals("GET /hello/{path}", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello/another", HTTP_URL); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello/another", URL_FULL); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); assertEquals("GET /hello/{path}", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, HttpMethod.GET, HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, HttpMethod.GET, HTTP_REQUEST_METHOD); assertEquals("/hello/{path}", server.getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(server, uri.getHost(), NET_HOST_NAME); - assertSemanticAttribute(server, (long) uri.getPort(), NET_HOST_PORT); + assertSemanticAttribute(server, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(server, (long) uri.getPort(), SERVER_PORT); assertTarget(server, uri.getPath() + "hello/another", null); assertEquals(client.getTraceId(), server.getTraceId()); } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java index fc828e8ccfbb6..6e2b092a30fac 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java @@ -2,14 +2,12 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_URL; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.NET_PEER_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_PEER_PORT; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; +import static io.opentelemetry.semconv.UrlAttributes.URL_FULL; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertTarget; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; @@ -85,20 +83,20 @@ void client() throws Exception { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals("GET", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello", HTTP_URL); - assertSemanticAttribute(client, uri.getHost(), NET_PEER_NAME); - assertSemanticAttribute(client, (long) uri.getPort(), NET_PEER_PORT); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello", URL_FULL); + assertSemanticAttribute(client, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(client, (long) uri.getPort(), SERVER_PORT); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); assertEquals("GET /hello", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, HttpMethod.GET, HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, HttpMethod.GET, HTTP_REQUEST_METHOD); assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(server, uri.getHost(), NET_HOST_NAME); - assertSemanticAttribute(server, (long) uri.getPort(), NET_HOST_PORT); + assertSemanticAttribute(server, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(server, (long) uri.getPort(), SERVER_PORT); assertTarget(server, uri.getPath() + "hello", null); assertEquals(client.getTraceId(), server.getTraceId()); @@ -119,20 +117,20 @@ void path() throws Exception { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(CLIENT, client.getKind()); assertEquals("GET", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello/naruto", HTTP_URL); - assertSemanticAttribute(client, uri.getHost(), NET_PEER_NAME); - assertSemanticAttribute(client, (long) uri.getPort(), NET_PEER_PORT); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello/naruto", URL_FULL); + assertSemanticAttribute(client, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(client, (long) uri.getPort(), SERVER_PORT); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); assertEquals("GET /hello/:name", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, HttpMethod.GET, HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, HttpMethod.GET, HTTP_REQUEST_METHOD); assertEquals("/hello/:name", server.getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(server, uri.getHost(), NET_HOST_NAME); - assertSemanticAttribute(server, (long) uri.getPort(), NET_HOST_PORT); + assertSemanticAttribute(server, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(server, (long) uri.getPort(), SERVER_PORT); assertTarget(server, uri.getPath() + "hello/naruto", null); assertEquals(client.getTraceId(), server.getTraceId()); @@ -153,20 +151,20 @@ void query() throws Exception { SpanData client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(CLIENT, client.getKind()); assertEquals("GET", client.getName()); - assertSemanticAttribute(client, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(client, HttpMethod.GET, HTTP_METHOD); - assertSemanticAttribute(client, uri.toString() + "hello?name=foo", HTTP_URL); - assertSemanticAttribute(client, uri.getHost(), NET_PEER_NAME); - assertSemanticAttribute(client, (long) uri.getPort(), NET_PEER_PORT); + assertSemanticAttribute(client, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(client, HttpMethod.GET, HTTP_REQUEST_METHOD); + assertSemanticAttribute(client, uri.toString() + "hello?name=foo", URL_FULL); + assertSemanticAttribute(client, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(client, (long) uri.getPort(), SERVER_PORT); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); assertEquals("GET /hello", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(server, HttpMethod.GET, HTTP_METHOD); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(server, HttpMethod.GET, HTTP_REQUEST_METHOD); assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(server, uri.getHost(), NET_HOST_NAME); - assertSemanticAttribute(server, (long) uri.getPort(), NET_HOST_PORT); + assertSemanticAttribute(server, uri.getHost(), SERVER_ADDRESS); + assertSemanticAttribute(server, (long) uri.getPort(), SERVER_PORT); assertTarget(server, uri.getPath() + "hello", "name=foo"); assertEquals(client.getTraceId(), server.getTraceId()); diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryForwardedTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryForwardedTest.java index 5ecf22ad53dbb..b9f70c472a4a3 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryForwardedTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryForwardedTest.java @@ -1,7 +1,7 @@ package io.quarkus.opentelemetry.deployment.instrumentation; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_CLIENT_IP; +import static io.opentelemetry.semconv.ClientAttributes.CLIENT_ADDRESS; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; import static org.hamcrest.Matchers.is; @@ -50,6 +50,6 @@ void trace() { List spans = testSpanExporter.getFinishedSpanItems(2); SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); - assertSemanticAttribute(server, "192.0.2.60", HTTP_CLIENT_IP); + assertSemanticAttribute(server, "192.0.2.60", CLIENT_ADDRESS); } } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryTest.java index b6134141327bb..0468b7b7561df 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryTest.java @@ -3,14 +3,14 @@ import static io.opentelemetry.api.common.AttributeKey.stringKey; import static io.opentelemetry.api.trace.SpanKind.INTERNAL; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_CLIENT_IP; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_SCHEME; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.USER_AGENT_ORIGINAL; +import static io.opentelemetry.semconv.ClientAttributes.CLIENT_ADDRESS; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; +import static io.opentelemetry.semconv.UrlAttributes.URL_SCHEME; +import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertTarget; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; @@ -89,12 +89,12 @@ void trace() throws NoSuchFieldException, IllegalAccessException, InvocationTarg Sampler sampler = TestUtil.getSampler(openTelemetry); SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); assertTarget(server, "/tracer", null); - assertSemanticAttribute(server, "http", HTTP_SCHEME); - assertSemanticAttribute(server, "localhost", NET_HOST_NAME); - assertSemanticAttribute(server, 8081L, NET_HOST_PORT); - assertSemanticAttribute(server, "127.0.0.1", HTTP_CLIENT_IP); + assertSemanticAttribute(server, "http", URL_SCHEME); + assertSemanticAttribute(server, "localhost", SERVER_ADDRESS); + assertSemanticAttribute(server, 8081L, SERVER_PORT); + assertSemanticAttribute(server, "127.0.0.1", CLIENT_ADDRESS); assertThat(textMapPropagators, arrayContainingInAnyOrder(W3CTraceContextPropagator.getInstance(), W3CBaggagePropagator.getInstance())); assertThat(idGenerator, instanceOf(IdGenerator.random().getClass())); @@ -116,12 +116,12 @@ void spanNameWithoutQueryString() { final SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); assertEquals("GET /tracer", server.getName()); - assertSemanticAttribute(server, (long) HTTP_OK, HTTP_STATUS_CODE); + assertSemanticAttribute(server, (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); assertTarget(server, "/tracer", "id=1"); - assertSemanticAttribute(server, "http", HTTP_SCHEME); - assertSemanticAttribute(server, "localhost", NET_HOST_NAME); - assertSemanticAttribute(server, 8081L, NET_HOST_PORT); - assertSemanticAttribute(server, "127.0.0.1", HTTP_CLIENT_IP); + assertSemanticAttribute(server, "http", URL_SCHEME); + assertSemanticAttribute(server, "localhost", SERVER_ADDRESS); + assertSemanticAttribute(server, 8081L, SERVER_PORT); + assertSemanticAttribute(server, "127.0.0.1", CLIENT_ADDRESS); assertNotNull(server.getAttributes().get(USER_AGENT_ORIGINAL)); SpanData internal = getSpanByKindAndParentId(spans, INTERNAL, server.getSpanId()); @@ -142,8 +142,8 @@ void spanPath() { assertEquals(1, spans.size()); assertEquals("GET /hello/:name", spans.get(0).getName()); - assertSemanticAttribute(spans.get(0), (long) HTTP_OK, HTTP_STATUS_CODE); - assertSemanticAttribute(spans.get(0), GET.toString(), HTTP_METHOD); + assertSemanticAttribute(spans.get(0), (long) HTTP_OK, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(spans.get(0), GET.toString(), HTTP_REQUEST_METHOD); assertEquals("/hello/:name", spans.get(0).getAttributes().get(HTTP_ROUTE)); } @@ -156,7 +156,7 @@ void notFound() { assertEquals("GET /*", spans.get(0).getName()); assertEquals("/*", spans.get(0).getAttributes().get(HTTP_ROUTE)); - assertSemanticAttribute(spans.get(0), (long) HTTP_NOT_FOUND, HTTP_STATUS_CODE); + assertSemanticAttribute(spans.get(0), (long) HTTP_NOT_FOUND, HTTP_RESPONSE_STATUS_CODE); } @Test @@ -170,8 +170,8 @@ void notFoundPath() { assertEquals(1, spans.size()); assertEquals("GET /hello/:name", spans.get(0).getName()); - assertSemanticAttribute(spans.get(0), (long) HTTP_NOT_FOUND, HTTP_STATUS_CODE); - assertSemanticAttribute(spans.get(0), GET.toString(), HTTP_METHOD); + assertSemanticAttribute(spans.get(0), (long) HTTP_NOT_FOUND, HTTP_RESPONSE_STATUS_CODE); + assertSemanticAttribute(spans.get(0), GET.toString(), HTTP_REQUEST_METHOD); assertEquals("/hello/:name", spans.get(0).getAttributes().get(HTTP_ROUTE)); } } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryXForwardedTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryXForwardedTest.java index 44c648d102ea2..cbcea7e09c1f7 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryXForwardedTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxOpenTelemetryXForwardedTest.java @@ -1,7 +1,7 @@ package io.quarkus.opentelemetry.deployment.instrumentation; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_CLIENT_IP; +import static io.opentelemetry.semconv.ClientAttributes.CLIENT_ADDRESS; import static io.quarkus.opentelemetry.deployment.common.SemconvResolver.assertSemanticAttribute; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; import static org.hamcrest.Matchers.is; @@ -50,6 +50,6 @@ void trace() { List spans = testSpanExporter.getFinishedSpanItems(2); SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); - assertSemanticAttribute(server, "203.0.113.195", HTTP_CLIENT_IP); + assertSemanticAttribute(server, "203.0.113.195", CLIENT_ADDRESS); } } diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/interceptor/WithSpanLegacyInterceptorTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/interceptor/WithSpanLegacyInterceptorTest.java deleted file mode 100644 index 6e334e0797421..0000000000000 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/interceptor/WithSpanLegacyInterceptorTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package io.quarkus.opentelemetry.deployment.interceptor; - -import static io.opentelemetry.api.trace.SpanKind.CLIENT; -import static io.opentelemetry.api.trace.SpanKind.INTERNAL; -import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; -import static java.net.HttpURLConnection.HTTP_OK; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.List; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; -import jakarta.inject.Inject; -import jakarta.ws.rs.client.ClientBuilder; -import jakarta.ws.rs.client.WebTarget; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.core.UriBuilder; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.extension.annotations.SpanAttribute; -import io.opentelemetry.extension.annotations.WithSpan; -import io.opentelemetry.sdk.trace.data.SpanData; -import io.quarkus.opentelemetry.deployment.common.TestSpanExporter; -import io.quarkus.opentelemetry.deployment.common.TestSpanExporterProvider; -import io.quarkus.runtime.StartupEvent; -import io.quarkus.test.QuarkusUnitTest; -import io.smallrye.config.SmallRyeConfig; -import io.vertx.ext.web.Router; - -public class WithSpanLegacyInterceptorTest { - @RegisterExtension - static final QuarkusUnitTest TEST = new QuarkusUnitTest() - .setArchiveProducer( - () -> ShrinkWrap.create(JavaArchive.class) - .addClass(SpanBean.class) - .addClasses(TestSpanExporter.class, TestSpanExporterProvider.class) - .addAsManifestResource( - "META-INF/services-config/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider", - "services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider") - .addAsResource("resource-config/application-no-metrics.properties", "application.properties")); - - @Inject - SpanBean spanBean; - @Inject - TestSpanExporter spanExporter; - - @AfterEach - void tearDown() { - spanExporter.reset(); - } - - @Test - void span() { - spanBean.span(); - List spanItems = spanExporter.getFinishedSpanItems(1); - assertEquals("SpanBean.span", spanItems.get(0).getName()); - assertEquals(INTERNAL, spanItems.get(0).getKind()); - } - - @Test - void spanName() { - spanBean.spanName(); - List spanItems = spanExporter.getFinishedSpanItems(1); - assertEquals("name", spanItems.get(0).getName()); - assertEquals(INTERNAL, spanItems.get(0).getKind()); - } - - @Test - void spanKind() { - spanBean.spanKind(); - List spanItems = spanExporter.getFinishedSpanItems(1); - assertEquals("SpanBean.spanKind", spanItems.get(0).getName()); - assertEquals(SERVER, spanItems.get(0).getKind()); - } - - @Test - void spanArgs() { - spanBean.spanArgs("argument"); - List spanItems = spanExporter.getFinishedSpanItems(1); - assertEquals("SpanBean.spanArgs", spanItems.get(0).getName()); - assertEquals(INTERNAL, spanItems.get(0).getKind()); - assertEquals("argument", spanItems.get(0).getAttributes().get(AttributeKey.stringKey("arg"))); - } - - @Test - void spanChild() { - spanBean.spanChild(); - List spans = spanExporter.getFinishedSpanItems(2); - - final SpanData parent = getSpanByKindAndParentId(spans, INTERNAL, "0000000000000000"); - assertEquals("SpanBean.spanChild", parent.getName()); - - final SpanData child = getSpanByKindAndParentId(spans, INTERNAL, parent.getSpanId()); - assertEquals("SpanChildBean.spanChild", child.getName()); - } - - @Test - void spanCdiRest() { - spanBean.spanRestClient(); - List spans = spanExporter.getFinishedSpanItems(4); - - final SpanData parent = getSpanByKindAndParentId(spans, INTERNAL, "0000000000000000"); - final SpanData child = getSpanByKindAndParentId(spans, INTERNAL, parent.getSpanId()); - final SpanData client = getSpanByKindAndParentId(spans, CLIENT, child.getSpanId()); - final SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); - } - - @ApplicationScoped - public static class SpanBean { - @WithSpan - public void span() { - - } - - @WithSpan("name") - public void spanName() { - - } - - @WithSpan(kind = SERVER) - public void spanKind() { - - } - - @WithSpan - public void spanArgs(@SpanAttribute(value = "arg") String arg) { - - } - - @Inject - SpanChildBean spanChildBean; - - @WithSpan - public void spanChild() { - spanChildBean.spanChild(); - } - - @Inject - SpanRestClient spanRestClient; - - @WithSpan - public void spanRestClient() { - spanRestClient.spanRestClient(); - } - } - - @ApplicationScoped - public static class SpanChildBean { - @WithSpan - public void spanChild() { - - } - } - - @ApplicationScoped - public static class SpanRestClient { - @Inject - SmallRyeConfig config; - - @WithSpan - public void spanRestClient() { - WebTarget target = ClientBuilder.newClient() - .target(UriBuilder.fromUri(config.getRawValue("test.url")).path("hello")); - Response response = target.request().get(); - assertEquals(HTTP_OK, response.getStatus()); - } - } - - @ApplicationScoped - public static class HelloRouter { - @Inject - Router router; - - public void register(@Observes StartupEvent ev) { - router.get("/hello").handler(rc -> rc.response().end("hello")); - } - } -} diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/traces/OpenTelemetryHttpCDILegacyTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/traces/OpenTelemetryHttpCDILegacyTest.java deleted file mode 100644 index fdb7218df99e9..0000000000000 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/traces/OpenTelemetryHttpCDILegacyTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package io.quarkus.opentelemetry.deployment.traces; - -import static io.opentelemetry.api.trace.SpanKind.INTERNAL; -import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; -import static io.quarkus.opentelemetry.deployment.common.TestUtil.assertStringAttribute; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.List; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.StringAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.opentelemetry.extension.annotations.WithSpan; -import io.opentelemetry.sdk.trace.data.SpanData; -import io.opentelemetry.semconv.SemanticAttributes; -import io.quarkus.opentelemetry.deployment.common.TestSpanExporter; -import io.quarkus.opentelemetry.deployment.common.TestSpanExporterProvider; -import io.quarkus.opentelemetry.deployment.common.TestUtil; -import io.quarkus.test.QuarkusUnitTest; -import io.restassured.RestAssured; - -public class OpenTelemetryHttpCDILegacyTest { - @RegisterExtension - static final QuarkusUnitTest TEST = new QuarkusUnitTest() - .setArchiveProducer( - () -> ShrinkWrap.create(JavaArchive.class) - .addClass(TestUtil.class) - .addClass(HelloResource.class) - .addClass(HelloBean.class) - .addClasses(TestSpanExporter.class, TestSpanExporterProvider.class) - .addAsResource(new StringAsset(TestSpanExporterProvider.class.getCanonicalName()), - "META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSpanExporterProvider")) - .withConfigurationResource("resource-config/application-no-metrics.properties"); - - @Inject - TestSpanExporter spanExporter; - - @AfterEach - void tearDown() { - spanExporter.reset(); - } - - @Test - void telemetry() { - RestAssured.when() - .get("/hello").then() - .statusCode(200) - .body(is("hello")); - - List spans = spanExporter.getFinishedSpanItems(2); - - SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); - assertEquals("GET /hello", server.getName()); - assertEquals(SERVER, server.getKind()); - // verify that OpenTelemetryServerFilter took place - assertStringAttribute(server, SemanticAttributes.CODE_NAMESPACE, - "io.quarkus.opentelemetry.deployment.traces.OpenTelemetryHttpCDILegacyTest$HelloResource"); - assertStringAttribute(server, SemanticAttributes.CODE_FUNCTION, "hello"); - - SpanData internal = getSpanByKindAndParentId(spans, INTERNAL, server.getSpanId()); - assertEquals("HelloBean.hello", internal.getName()); - assertEquals(INTERNAL, internal.getKind()); - - assertEquals(internal.getParentSpanId(), server.getSpanId()); - } - - @Test - void withSpan() { - RestAssured.when() - .get("/hello/withSpan").then() - .statusCode(200) - .body(is("hello")); - - List spans = spanExporter.getFinishedSpanItems(3); - - final SpanData server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); - assertEquals("GET /hello/withSpan", server.getName()); - - final SpanData internalFromBean = getSpanByKindAndParentId(spans, INTERNAL, server.getSpanId()); - assertEquals("withSpan", internalFromBean.getName()); - - final SpanData internalFromWithSpan = getSpanByKindAndParentId(spans, INTERNAL, internalFromBean.getSpanId()); - assertEquals("HelloBean.hello", internalFromWithSpan.getName()); - - assertThat(internalFromBean.getTraceId()).isIn(internalFromWithSpan.getTraceId(), server.getTraceId()); - } - - @Path("/hello") - public static class HelloResource { - @Inject - HelloBean helloBean; - - @GET - public String hello() { - return helloBean.hello(); - } - - @GET - @Path("/withSpan") - @WithSpan("withSpan") - public String withSpan() { - return helloBean.hello(); - } - } - - @ApplicationScoped - public static class HelloBean { - @WithSpan - public String hello() { - return "hello"; - } - } -} diff --git a/extensions/opentelemetry/runtime/pom.xml b/extensions/opentelemetry/runtime/pom.xml index 833cc2d93eb6b..5d3624fa1df12 100644 --- a/extensions/opentelemetry/runtime/pom.xml +++ b/extensions/opentelemetry/runtime/pom.xml @@ -90,10 +90,6 @@ io.opentelemetry opentelemetry-sdk - - io.opentelemetry - opentelemetry-extension-annotations - io.opentelemetry opentelemetry-sdk-extension-autoconfigure-spi @@ -104,7 +100,7 @@ io.opentelemetry - opentelemetry-api-events + opentelemetry-api-incubator io.opentelemetry.instrumentation @@ -120,7 +116,7 @@ io.opentelemetry.instrumentation - opentelemetry-instrumentation-api-semconv + opentelemetry-instrumentation-api-incubator io.opentelemetry.semconv diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/AutoConfiguredOpenTelemetrySdkBuilderCustomizer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/AutoConfiguredOpenTelemetrySdkBuilderCustomizer.java index ccc5ec9d172d2..e601962c7b01c 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/AutoConfiguredOpenTelemetrySdkBuilderCustomizer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/AutoConfiguredOpenTelemetrySdkBuilderCustomizer.java @@ -1,6 +1,5 @@ package io.quarkus.opentelemetry.runtime; -import static io.quarkus.opentelemetry.runtime.OpenTelemetryUtil.getSemconvStabilityOptin; import static java.lang.Boolean.TRUE; import static java.util.Collections.emptyList; @@ -103,8 +102,6 @@ public boolean test(String sn) { @Singleton final class SamplerCustomizer implements AutoConfiguredOpenTelemetrySdkBuilderCustomizer { - private static final String OTEL_SEMCONV_STABILITY_OPT_IN = "otel.semconv-stability.opt-in"; - private final OTelBuildConfig oTelBuildConfig; private final OTelRuntimeConfig oTelRuntimeConfig; private final List sampler; @@ -138,10 +135,7 @@ public Sampler apply(Sampler existingSampler, ConfigProperties configProperties) // make sure dropped targets are not sampled if (!dropTargets.isEmpty()) { - return new DropTargetsSampler(effectiveSampler, - dropTargets, - getSemconvStabilityOptin( - configProperties.getString(OTEL_SEMCONV_STABILITY_OPT_IN))); + return new DropTargetsSampler(effectiveSampler, dropTargets); } else { return effectiveSampler; } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java index 0967428012cb2..bcf640e928bdf 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java @@ -14,7 +14,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.events.GlobalEventEmitterProvider; +import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; import io.opentelemetry.context.ContextStorage; import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; import io.quarkus.arc.SyntheticCreationalContext; @@ -35,7 +35,7 @@ public class OpenTelemetryRecorder { @StaticInit public void resetGlobalOpenTelemetryForDevMode() { GlobalOpenTelemetry.resetForTest(); - GlobalEventEmitterProvider.resetForTest(); + GlobalEventLoggerProvider.resetForTest(); } @RuntimeInit diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java index 1b2894cc49a25..de8326f931aeb 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtil.java @@ -12,7 +12,6 @@ import io.opentelemetry.api.trace.SpanContext; import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.ReadableSpan; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; import io.quarkus.vertx.core.runtime.VertxMDC; public final class OpenTelemetryUtil { @@ -112,16 +111,4 @@ public static void clearMDCData(io.vertx.core.Context vertxContext) { vertxMDC.remove(PARENT_ID, vertxContext); vertxMDC.remove(SAMPLED, vertxContext); } - - public static SemconvStabilityType getSemconvStabilityOptin(String config) { - if (config == null || config.isBlank()) { - return SemconvStabilityType.HTTP_OLD; - } - - try { - return SemconvStabilityType.fromValue(config); - } catch (IllegalArgumentException e) { - return SemconvStabilityType.HTTP_OLD; - } - } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/OTelRuntimeConfig.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/OTelRuntimeConfig.java index 8960f04d76f53..ef7ca8abcfab8 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/OTelRuntimeConfig.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/OTelRuntimeConfig.java @@ -82,21 +82,6 @@ public interface OTelRuntimeConfig { */ InstrumentRuntimeConfig instrument(); - /** - * Opt-in to emit stable OpenTelemetry semantic conventions or a - * duplication of the old plus the new semantic convention attribute names. - *

- * - http - emit the new, stable HTTP and networking attributes, and stop emitting the old - * experimental HTTP and networking attributes that the instrumentation emitted previously. - *

- * - http/dup - emit both the old and the stable HTTP and networking attributes, allowing - * for a more seamless transition. - *

- * The default, by not defining a property value, will mean the use of the old legacy semantic attribute names. - */ - @WithName("semconv-stability.opt-in") - Optional otelSemconvStabilityOptIn(); - /** * Prioritize OpenTelemetry configuration otel. on top of Quarkus OpenTelemetry configuration * quarkus.otel. diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/SemconvStabilityType.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/SemconvStabilityType.java deleted file mode 100644 index be0d7f71ba66d..0000000000000 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/SemconvStabilityType.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.quarkus.opentelemetry.runtime.config.runtime; - -public enum SemconvStabilityType { - /** - * Emit the new stable convention names - */ - HTTP("http"), - /** - * Emit the old unstable plus the new stable convention names for transition purposes - */ - HTTP_DUP("http/dup"), - /** - * Emit the old unstable convention names. - *

- * This is a non standard property name, only used in Quarkus. - */ - HTTP_OLD("http/old"); - - private final String value; - - SemconvStabilityType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public static SemconvStabilityType fromValue(String value) { - for (SemconvStabilityType type : values()) { - if (type.value.equals(value)) { - return type; - } - } - throw new IllegalArgumentException("No enum constant with value: " + value); - } - - static class Constants { - public static final String HTTP = "http"; - public static final String HTTP_DUP = "http/dup"; - public static final String HTTP_OLD = "http/old"; - } -} diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/sender/VertxHttpSender.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/sender/VertxHttpSender.java index e3178c18f856e..aa56e704d2699 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/sender/VertxHttpSender.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/sender/VertxHttpSender.java @@ -18,6 +18,7 @@ import java.util.zip.GZIPOutputStream; import io.opentelemetry.exporter.internal.http.HttpSender; +import io.opentelemetry.exporter.internal.marshal.Marshaler; import io.opentelemetry.sdk.common.CompletableResultCode; import io.opentelemetry.sdk.internal.ThrottlingLogger; import io.quarkus.vertx.core.runtime.BufferOutputStream; @@ -91,7 +92,7 @@ private static String determineBasePath(URI baseUri) { } @Override - public void send(Consumer marshaler, + public void send(Marshaler marshaler, int contentLength, Consumer onHttpResponseRead, Consumer onError) { @@ -178,7 +179,7 @@ private static class ClientRequestSuccessHandler implements Handler onHttpResponseRead; private final Consumer onError; - private final Consumer marshaler; + private final Marshaler marshaler; private final int attemptNumber; private final Supplier isShutdown; @@ -190,7 +191,7 @@ public ClientRequestSuccessHandler(HttpClient client, int contentLength, Consumer onHttpResponseRead, Consumer onError, - Consumer marshaler, + Marshaler marshaler, int attemptNumber, Supplier isShutdown) { this.client = client; @@ -281,12 +282,16 @@ public byte[] responseBody() { if (compressionEnabled) { clientRequest.putHeader("Content-Encoding", "gzip"); try (var gzos = new GZIPOutputStream(os)) { - marshaler.accept(gzos); + marshaler.writeBinaryTo(gzos); } catch (IOException e) { throw new IllegalStateException(e); } } else { - marshaler.accept(os); + try { + marshaler.writeBinaryTo(os); + } catch (IOException e) { + throw new IllegalStateException(e); + } } if (!headers.isEmpty()) { diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/graal/Substitutions.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/graal/Substitutions.java index f5809d4d27a19..ea5dcf5d13b34 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/graal/Substitutions.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/graal/Substitutions.java @@ -7,10 +7,11 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; -import io.opentelemetry.api.events.EventEmitterProvider; +import io.opentelemetry.api.incubator.events.EventLoggerProvider; import io.opentelemetry.api.metrics.MeterProvider; import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; +import io.opentelemetry.sdk.logs.LogRecordProcessor; import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder; import io.opentelemetry.sdk.logs.export.LogRecordExporter; @@ -26,15 +27,16 @@ static void configureLoggerProvider( SpiHelper spiHelper, MeterProvider meterProvider, BiFunction logRecordExporterCustomizer, + BiFunction logRecordProcessorCustomizer, List closeables) { // Logs not supported yet. No need to call LogRecordExporterConfiguration.configureExporter } } - @TargetClass(className = "io.opentelemetry.api.events.GlobalEventEmitterProvider") + @TargetClass(className = "io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider") static final class Target_GlobalEventEmitterProvider { @Substitute - public static void set(EventEmitterProvider eventEmitterProvider) { + public static void set(EventLoggerProvider eventEmitterProvider) { // do nothing. We don't support events yet. Default is EventEmitterProvider.noop() } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java index d9c332d86c313..6e4b5fef9a29f 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSampler.java @@ -9,19 +9,15 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingResult; import io.opentelemetry.semconv.SemanticAttributes; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; public class DropTargetsSampler implements Sampler { private final Sampler sampler; private final List dropTargets; - private final SemconvStabilityType semconvStabilityOptin; public DropTargetsSampler(final Sampler sampler, - final List dropTargets, - final SemconvStabilityType semconvStabilityOptin) { + final List dropTargets) { this.sampler = sampler; this.dropTargets = dropTargets; - this.semconvStabilityOptin = semconvStabilityOptin; } @Override @@ -29,16 +25,11 @@ public SamplingResult shouldSample(Context parentContext, String traceId, String Attributes attributes, List parentLinks) { if (spanKind.equals(SpanKind.SERVER)) { - String target; - if (SemconvStabilityType.HTTP.equals(semconvStabilityOptin) || - SemconvStabilityType.HTTP_DUP.equals(semconvStabilityOptin)) { - // HTTP_TARGET was split into url.path and url.query - String path = attributes.get(SemanticAttributes.URL_PATH); - String query = attributes.get(SemanticAttributes.URL_QUERY); - target = path + (query == null ? "" : "?" + query); - } else { - target = attributes.get(SemanticAttributes.HTTP_TARGET); - } + // HTTP_TARGET was split into url.path and url.query + String path = attributes.get(SemanticAttributes.URL_PATH); + String query = attributes.get(SemanticAttributes.URL_QUERY); + String target = path + (query == null ? "" : "?" + query); + if (shouldDrop(target)) { return SamplingResult.drop(); } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/AddingSpanAttributesInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/AddingSpanAttributesInterceptor.java index 3eecc0f3cade5..37d47ed5f41d7 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/AddingSpanAttributesInterceptor.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/AddingSpanAttributesInterceptor.java @@ -60,19 +60,12 @@ public String[] extract(final Method method, final Parameter[] parameters) { } private static String attributeName(Parameter parameter) { - String value; + String value = null; SpanAttribute spanAttribute = parameter.getDeclaredAnnotation(SpanAttribute.class); - if (spanAttribute == null) { - // Needed because SpanAttribute cannot be transformed - io.opentelemetry.extension.annotations.SpanAttribute legacySpanAttribute = parameter.getDeclaredAnnotation( - io.opentelemetry.extension.annotations.SpanAttribute.class); - if (legacySpanAttribute == null) { - return null; - } else { - value = legacySpanAttribute.value(); - } - } else { + if (spanAttribute != null) { value = spanAttribute.value(); + } else { + return null; } if (!value.isEmpty()) { diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/WithSpanInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/WithSpanInterceptor.java index 0061eb3c5b668..4e56bbdf4b0ea 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/WithSpanInterceptor.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/WithSpanInterceptor.java @@ -22,11 +22,11 @@ import io.opentelemetry.instrumentation.annotations.WithSpan; import io.opentelemetry.instrumentation.api.annotation.support.MethodSpanAttributesExtractor; import io.opentelemetry.instrumentation.api.annotation.support.ParameterAttributeNamesExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.util.SpanNames; import io.quarkus.arc.ArcInvocationContext; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; @@ -210,19 +210,12 @@ public String[] extract(final Method method, final Parameter[] parameters) { } private static String attributeName(Parameter parameter) { - String value; + String value = null; SpanAttribute spanAttribute = parameter.getDeclaredAnnotation(SpanAttribute.class); - if (spanAttribute == null) { - // Needed because SpanAttribute cannot be transformed - io.opentelemetry.extension.annotations.SpanAttribute legacySpanAttribute = parameter.getDeclaredAnnotation( - io.opentelemetry.extension.annotations.SpanAttribute.class); - if (legacySpanAttribute == null) { - return null; - } else { - value = legacySpanAttribute.value(); - } - } else { + if (spanAttribute != null) { value = spanAttribute.value(); + } else { + return null; } if (!value.isEmpty()) { diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java index 11873ab929225..40aac71c43e0b 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java @@ -1,7 +1,5 @@ package io.quarkus.opentelemetry.runtime.tracing.intrumentation; -import static io.quarkus.opentelemetry.runtime.OpenTelemetryUtil.getSemconvStabilityOptin; - import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; @@ -45,11 +43,11 @@ public Consumer getVertxTracingOptions() { /* RUNTIME INIT */ @RuntimeInit public void setupVertxTracer(BeanContainer beanContainer, boolean sqlClientAvailable, - boolean redisClientAvailable, final String semconvStability) { + boolean redisClientAvailable) { OpenTelemetry openTelemetry = beanContainer.beanInstance(OpenTelemetry.class); List> tracers = new ArrayList<>(4); if (config.getValue().instrument().vertxHttp()) { - tracers.add(new HttpInstrumenterVertxTracer(openTelemetry, getSemconvStabilityOptin(semconvStability))); + tracers.add(new HttpInstrumenterVertxTracer(openTelemetry)); } if (config.getValue().instrument().vertxEventBus()) { tracers.add(new EventBusInstrumenterVertxTracer(openTelemetry)); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcAttributesGetter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcAttributesGetter.java index 9cc912eca23d3..6a8bf1c6016ba 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcAttributesGetter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcAttributesGetter.java @@ -1,6 +1,6 @@ package io.quarkus.opentelemetry.runtime.tracing.intrumentation.grpc; -import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcAttributesGetter; enum GrpcAttributesGetter implements RpcAttributesGetter { INSTANCE; diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingClientInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingClientInterceptor.java index d66ec95ff92c7..1901857ccdd01 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingClientInterceptor.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingClientInterceptor.java @@ -17,9 +17,9 @@ import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.context.propagation.TextMapSetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcClientAttributesExtractor; import io.quarkus.grpc.GlobalInterceptor; @Singleton diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingServerInterceptor.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingServerInterceptor.java index f059dc931561c..7d728a0e1c13c 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingServerInterceptor.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/grpc/GrpcTracingServerInterceptor.java @@ -6,11 +6,12 @@ import java.net.SocketAddress; import java.util.Collections; +import javax.annotation.Nullable; + import jakarta.inject.Singleton; import io.grpc.ForwardingServerCall.SimpleForwardingServerCall; import io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener; -import io.grpc.Grpc; import io.grpc.Metadata; import io.grpc.ServerCall; import io.grpc.ServerCallHandler; @@ -20,14 +21,13 @@ import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.context.propagation.TextMapGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter; import io.quarkus.grpc.GlobalInterceptor; @Singleton @@ -44,9 +44,8 @@ public GrpcTracingServerInterceptor(final OpenTelemetry openTelemetry) { GrpcServerNetworkAttributesGetter getter = new GrpcServerNetworkAttributesGetter(); builder.addAttributesExtractor(RpcServerAttributesExtractor.create(GrpcAttributesGetter.INSTANCE)) - .addAttributesExtractor( - ServerAttributesExtractor.createForServerSide(getter)) - .addAttributesExtractor(ClientAttributesExtractor.create(getter)) + .addAttributesExtractor(ServerAttributesExtractor.create(getter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(getter)) .addAttributesExtractor(new GrpcStatusCodeExtractor()) .setSpanStatusExtractor(new GrpcSpanStatusExtractor()); @@ -72,8 +71,7 @@ public ServerCall.Listener interceptCall( } static class GrpcServerNetworkAttributesGetter implements NetworkAttributesGetter, - ServerAttributesGetter, - ClientAttributesGetter { + ServerAttributesGetter { @Override public String getServerAddress(GrpcRequest grpcRequest) { @@ -86,19 +84,18 @@ public Integer getServerPort(GrpcRequest grpcRequest) { } @Override - public InetSocketAddress getClientInetSocketAddress(GrpcRequest grpcRequest, Status status) { - SocketAddress socketAddress = grpcRequest.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR); - if (socketAddress instanceof InetSocketAddress) { - return (InetSocketAddress) socketAddress; - } + public InetSocketAddress getNetworkLocalInetSocketAddress( + GrpcRequest grpcRequest, @Nullable Status status) { + // TODO: later version introduces TRANSPORT_ATTR_LOCAL_ADDR, might be a good idea to use it return null; } @Override - public InetSocketAddress getServerInetSocketAddress(GrpcRequest grpcRequest, Status status) { - SocketAddress socketAddress = grpcRequest.getAttributes().get(Grpc.TRANSPORT_ATTR_LOCAL_ADDR); - if (socketAddress instanceof InetSocketAddress) { - return (InetSocketAddress) socketAddress; + public InetSocketAddress getNetworkPeerInetSocketAddress( + GrpcRequest request, @Nullable Status status) { + SocketAddress address = request.getPeerSocketAddress(); + if (address instanceof InetSocketAddress) { + return (InetSocketAddress) address; } return null; } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java index c46e2ab4d2ade..c3ea205f6c2cf 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java @@ -23,11 +23,10 @@ import io.opentelemetry.context.propagation.TextMapSetter; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.semconv.SemanticAttributes; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor; +import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor; import io.quarkus.arc.Unremovable; import io.quarkus.opentelemetry.runtime.QuarkusContextStorage; @@ -160,11 +159,6 @@ public String getUrlFull(final ClientRequestContext request) { return uri.toString(); } - @Override - public String getTransport(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) { - return SemanticAttributes.NetTransportValues.IP_TCP; - } - @Override public String getServerAddress(ClientRequestContext clientRequestContext) { return clientRequestContext.getUri().getHost(); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/EventBusInstrumenterVertxTracer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/EventBusInstrumenterVertxTracer.java index 286c38c8aa617..e3aff4e8e2383 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/EventBusInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/EventBusInstrumenterVertxTracer.java @@ -1,16 +1,16 @@ package io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx; -import static io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation.PUBLISH; -import static io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation.RECEIVE; +import static io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation.PUBLISH; +import static io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation.RECEIVE; import static io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig.INSTRUMENTATION_NAME; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.context.propagation.TextMapGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessagingSpanNameExtractor; import io.vertx.core.eventbus.Message; import io.vertx.core.spi.tracing.TagExtractor; @@ -99,29 +99,49 @@ public String getDestination(final Message message) { return message.address(); } + @Override + public String getDestinationTemplate(Message message) { + return ""; + } + @Override public boolean isTemporaryDestination(final Message message) { return false; } + @Override + public boolean isAnonymousDestination(Message message) { + return false; + } + @Override public String getConversationId(final Message message) { return message.replyAddress(); } @Override - public Long getMessagePayloadSize(final Message message) { - return null; + public Long getMessageBodySize(Message message) { + return 0L; } @Override - public Long getMessagePayloadCompressedSize(final Message message) { - return null; + public Long getMessageEnvelopeSize(Message message) { + return 0L; } @Override public String getMessageId(final Message message, final Message message2) { return null; } + + @Override + public String getClientId(Message message) { + return ""; + } + + @Override + public Long getBatchMessageCount(Message message, Message message2) { + return 0L; + } } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java index 32ef18de5b1e3..40b3030204c24 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java @@ -1,8 +1,9 @@ package io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx; -import static io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRouteSource.SERVER_FILTER; +import static io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteSource.SERVER_FILTER; import static io.opentelemetry.semconv.SemanticAttributes.CLIENT_ADDRESS; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_CLIENT_IP; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_BODY_SIZE; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_BODY_SIZE; import static io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig.INSTRUMENTATION_NAME; import java.net.URI; @@ -22,15 +23,13 @@ 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.HttpClientAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRoute; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRouteBiGetter; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; -import io.opentelemetry.semconv.SemanticAttributes; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRoute; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBiGetter; +import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor; +import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor; import io.smallrye.common.vertx.VertxContext; import io.vertx.core.Context; import io.vertx.core.MultiMap; @@ -52,8 +51,8 @@ public class HttpInstrumenterVertxTracer implements InstrumenterVertxTracer serverInstrumenter; private final Instrumenter clientInstrumenter; - public HttpInstrumenterVertxTracer(final OpenTelemetry openTelemetry, final SemconvStabilityType semconvStability) { - serverInstrumenter = getServerInstrumenter(openTelemetry, semconvStability); + public HttpInstrumenterVertxTracer(final OpenTelemetry openTelemetry) { + serverInstrumenter = getServerInstrumenter(openTelemetry); clientInstrumenter = getClientInstrumenter(openTelemetry); } @@ -137,8 +136,7 @@ public HttpRequest writableHeaders( return WriteHeadersHttpRequest.request(request, headers); } - private static Instrumenter getServerInstrumenter(final OpenTelemetry openTelemetry, - final SemconvStabilityType semconvStability) { + private static Instrumenter getServerInstrumenter(final OpenTelemetry openTelemetry) { ServerAttributesExtractor serverAttributesExtractor = new ServerAttributesExtractor(); InstrumenterBuilder serverBuilder = Instrumenter.builder( @@ -150,7 +148,7 @@ private static Instrumenter getServerInstrumenter(fin .setSpanStatusExtractor(HttpSpanStatusExtractor.create(serverAttributesExtractor)) .addAttributesExtractor( HttpServerAttributesExtractor.create(serverAttributesExtractor)) - .addAttributesExtractor(new AdditionalServerAttributesExtractor(semconvStability)) + .addAttributesExtractor(new AdditionalServerAttributesExtractor()) .addContextCustomizer(HttpServerRoute.create(serverAttributesExtractor)) .buildServerInstrumenter(new HttpRequestTextMapGetter()); } @@ -167,7 +165,7 @@ private static Instrumenter getClientInstrumenter(fin return clientBuilder .setSpanStatusExtractor(HttpSpanStatusExtractor.create(serverAttributesExtractor)) .addAttributesExtractor( - io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor.create( + io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor.create( httpClientAttributesExtractor)) .buildClientInstrumenter(new HttpRequestTextMapSetter()); } @@ -199,12 +197,12 @@ public String get(final io.opentelemetry.context.Context context, final HttpRequ private static class ServerAttributesExtractor implements HttpServerAttributesGetter { @Override - public String getTransport(HttpRequest httpRequest) { - return null; + public String getNetworkProtocolName(HttpRequest request, HttpResponse response) { + return "http"; } @Override - public String getServerAddress(HttpRequest httpRequest) { + public String getNetworkPeerAddress(HttpRequest httpRequest, HttpResponse httpResponse) { if (httpRequest instanceof HttpServerRequest) { return VertxUtil.extractRemoteHostname((HttpServerRequest) httpRequest); } @@ -212,7 +210,7 @@ public String getServerAddress(HttpRequest httpRequest) { } @Override - public Integer getServerPort(HttpRequest httpRequest) { + public Integer getNetworkPeerPort(HttpRequest httpRequest, HttpResponse httpResponse) { if (httpRequest instanceof HttpServerRequest) { Long remoteHostPort = VertxUtil.extractRemoteHostPort((HttpServerRequest) httpRequest); if (remoteHostPort == null) { @@ -223,16 +221,6 @@ public Integer getServerPort(HttpRequest httpRequest) { return null; } - @Override - public String getNetworkProtocolName(HttpRequest request, HttpResponse response) { - return "http"; - } - - @Override - public String getNetworkProtocolVersion(HttpRequest request, HttpResponse response) { - return getHttpVersion(request); - } - @Override public String getUrlPath(final HttpRequest request) { try { @@ -285,28 +273,9 @@ public Integer getHttpResponseStatusCode(HttpRequest httpRequest, HttpResponse h public List getHttpResponseHeader(final HttpRequest request, final HttpResponse response, final String name) { return response != null ? response.headers().getAll(name) : Collections.emptyList(); } - - private static Long getContentLength(final MultiMap headers) { - String contentLength = headers.get(HttpHeaders.CONTENT_LENGTH); - if (contentLength != null && contentLength.length() > 0) { - try { - return Long.valueOf(contentLength); - } catch (NumberFormatException e) { - return null; - } - } else { - return null; - } - } } private static class AdditionalServerAttributesExtractor implements AttributesExtractor { - private final SemconvStabilityType semconvStability; - - public AdditionalServerAttributesExtractor(final SemconvStabilityType semconvStability) { - this.semconvStability = semconvStability; - } - @Override public void onStart( final AttributesBuilder attributes, @@ -316,18 +285,7 @@ public void onStart( if (httpRequest instanceof HttpServerRequest) { String clientIp = VertxUtil.extractClientIP((HttpServerRequest) httpRequest); if (clientIp != null) { - switch (semconvStability) { - case HTTP_OLD: - attributes.put(HTTP_CLIENT_IP, clientIp); - break; - case HTTP_DUP: - attributes.put(HTTP_CLIENT_IP, clientIp); - attributes.put(CLIENT_ADDRESS, clientIp); - break; - case HTTP: - attributes.put(CLIENT_ADDRESS, clientIp); - break; - } + attributes.put(CLIENT_ADDRESS, clientIp); } } } @@ -339,7 +297,21 @@ public void onEnd( final HttpRequest httpRequest, final HttpResponse httpResponse, final Throwable error) { + attributes.put(HTTP_REQUEST_BODY_SIZE, getContentLength(httpRequest.headers())); + attributes.put(HTTP_RESPONSE_BODY_SIZE, getContentLength(httpResponse.headers())); + } + private static Long getContentLength(final MultiMap headers) { + String contentLength = headers.get(HttpHeaders.CONTENT_LENGTH); + if (contentLength != null && contentLength.length() > 0) { + try { + return Long.valueOf(contentLength); + } catch (NumberFormatException e) { + return null; + } + } else { + return null; + } } } @@ -385,11 +357,6 @@ public List getHttpResponseHeader(final HttpRequest request, final HttpR return response.headers().getAll(name); } - @Override - public String getTransport(HttpRequest httpClientRequest, HttpResponse httpClientResponse) { - return SemanticAttributes.NetTransportValues.IP_TCP; - } - @Override public String getServerAddress(HttpRequest httpRequest) { return httpRequest.remoteAddress().hostName(); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/RedisClientInstrumenterVertxTracer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/RedisClientInstrumenterVertxTracer.java index 445cd66c087a4..06c5db88ee48c 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/RedisClientInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/RedisClientInstrumenterVertxTracer.java @@ -7,13 +7,13 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; 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.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesGetter; -import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil; import io.opentelemetry.semconv.SemanticAttributes; import io.vertx.core.Context; diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/SqlClientInstrumenterVertxTracer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/SqlClientInstrumenterVertxTracer.java index b8bfdda2a408a..527459568968b 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/SqlClientInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/SqlClientInstrumenterVertxTracer.java @@ -6,10 +6,10 @@ import java.util.function.BiConsumer; import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesExtractor; import io.vertx.core.Context; import io.vertx.core.spi.tracing.SpanKind; import io.vertx.core.spi.tracing.TagExtractor; @@ -117,7 +117,7 @@ public String connectionString() { } static class SqlClientAttributesGetter implements - io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesGetter { + io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter { @Override public String getRawStatement(final QueryTrace queryTrace) { diff --git a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtilTest.java b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtilTest.java index 34903c96f90a1..eebe37eee8a85 100644 --- a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtilTest.java +++ b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/OpenTelemetryUtilTest.java @@ -17,7 +17,6 @@ import io.opentelemetry.context.Context; import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.SpanProcessor; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; public class OpenTelemetryUtilTest { @@ -119,16 +118,4 @@ public void testGetSpanData_nullValue() { Map actual = OpenTelemetryUtil.getSpanData(null); assertEquals(0, actual.size()); } - - @Test - public void testSemconvOptin() { - assertEquals(SemconvStabilityType.HTTP_OLD, - OpenTelemetryUtil.getSemconvStabilityOptin(null)); - assertEquals(SemconvStabilityType.HTTP_OLD, - OpenTelemetryUtil.getSemconvStabilityOptin(SemconvStabilityType.HTTP_OLD.getValue())); - assertEquals(SemconvStabilityType.HTTP, - OpenTelemetryUtil.getSemconvStabilityOptin(SemconvStabilityType.HTTP.getValue())); - assertEquals(SemconvStabilityType.HTTP_DUP, - OpenTelemetryUtil.getSemconvStabilityOptin(SemconvStabilityType.HTTP_DUP.getValue())); - } } diff --git a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSamplerTest.java b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSamplerTest.java index 287784eacb258..dbeba5fcf7ff3 100644 --- a/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSamplerTest.java +++ b/extensions/opentelemetry/runtime/src/test/java/io/quarkus/opentelemetry/runtime/tracing/DropTargetsSamplerTest.java @@ -15,44 +15,33 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingResult; import io.opentelemetry.semconv.SemanticAttributes; -import io.quarkus.opentelemetry.runtime.config.runtime.SemconvStabilityType; class DropTargetsSamplerTest { @Test void testDropTargets() { CountingSampler countingSampler = new CountingSampler(); - SemconvStabilityType semconvStabilityOptin = getSemconvStabilityOptin( - System.getProperty("quarkus.otel.semconv-stability.opt-in")); - var sut = new DropTargetsSampler(countingSampler, List.of("/q/swagger-ui", "/q/swagger-ui*"), - semconvStabilityOptin); + var sut = new DropTargetsSampler(countingSampler, List.of("/q/swagger-ui", "/q/swagger-ui*")); - assertEquals(SamplingResult.recordAndSample(), getShouldSample(sut, "/other", semconvStabilityOptin)); + assertEquals(SamplingResult.recordAndSample(), getShouldSample(sut, "/other")); assertEquals(1, countingSampler.count.get()); - assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui", semconvStabilityOptin)); + assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui")); assertEquals(1, countingSampler.count.get()); - assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui/", semconvStabilityOptin)); + assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui/")); assertEquals(1, countingSampler.count.get()); - assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui/whatever", semconvStabilityOptin)); + assertEquals(SamplingResult.drop(), getShouldSample(sut, "/q/swagger-ui/whatever")); assertEquals(1, countingSampler.count.get()); - assertEquals(SamplingResult.recordAndSample(), getShouldSample(sut, "/q/test", semconvStabilityOptin)); + assertEquals(SamplingResult.recordAndSample(), getShouldSample(sut, "/q/test")); assertEquals(2, countingSampler.count.get()); } - private static SamplingResult getShouldSample(DropTargetsSampler sut, - String target, - SemconvStabilityType semconvStabilityOptin) { - if (SemconvStabilityType.HTTP.equals(semconvStabilityOptin) || - SemconvStabilityType.HTTP_DUP.equals(semconvStabilityOptin)) { - return sut.shouldSample(null, null, null, SpanKind.SERVER, - Attributes.of(SemanticAttributes.URL_PATH, target), null); - } + private static SamplingResult getShouldSample(DropTargetsSampler sut, String target) { return sut.shouldSample(null, null, null, SpanKind.SERVER, - Attributes.of(SemanticAttributes.HTTP_TARGET, target), null); + Attributes.of(SemanticAttributes.URL_PATH, target), null); } private static final class CountingSampler implements Sampler { diff --git a/extensions/quartz/runtime/pom.xml b/extensions/quartz/runtime/pom.xml index 037f950bd19d5..5b8b60e382cad 100644 --- a/extensions/quartz/runtime/pom.xml +++ b/extensions/quartz/runtime/pom.xml @@ -63,7 +63,7 @@ io.opentelemetry.instrumentation - opentelemetry-instrumentation-api-semconv + opentelemetry-instrumentation-api-incubator true diff --git a/integration-tests/opentelemetry-grpc/src/test/java/io/quarkus/it/opentelemetry/grpc/OpenTelemetryGrpcTest.java b/integration-tests/opentelemetry-grpc/src/test/java/io/quarkus/it/opentelemetry/grpc/OpenTelemetryGrpcTest.java index 2bf865fd12473..f68b38bacf864 100644 --- a/integration-tests/opentelemetry-grpc/src/test/java/io/quarkus/it/opentelemetry/grpc/OpenTelemetryGrpcTest.java +++ b/integration-tests/opentelemetry-grpc/src/test/java/io/quarkus/it/opentelemetry/grpc/OpenTelemetryGrpcTest.java @@ -2,16 +2,16 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_TARGET; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_HOST_PORT; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; import static io.opentelemetry.semconv.SemanticAttributes.RPC_GRPC_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.RPC_METHOD; import static io.opentelemetry.semconv.SemanticAttributes.RPC_SERVICE; import static io.opentelemetry.semconv.SemanticAttributes.RPC_SYSTEM; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; +import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; import static io.restassured.RestAssured.given; import static io.restassured.RestAssured.when; import static java.net.HttpURLConnection.HTTP_OK; @@ -66,9 +66,9 @@ void grpc() { assertEquals(SpanKind.SERVER.toString(), rest.get("kind")); assertEquals("GET /grpc/{name}", rest.get("name")); assertEquals("/grpc/{name}", getAttributes(rest).get(HTTP_ROUTE.getKey())); - assertEquals("/grpc/Naruto", getAttributes(rest).get(HTTP_TARGET.getKey())); - assertEquals(HTTP_OK, getAttributes(rest).get(HTTP_STATUS_CODE.getKey())); - assertEquals(HttpMethod.GET.name(), getAttributes(rest).get(HTTP_METHOD.getKey())); + assertEquals("/grpc/Naruto", getAttributes(rest).get(URL_PATH.getKey())); + assertEquals(HTTP_OK, getAttributes(rest).get(HTTP_RESPONSE_STATUS_CODE.getKey())); + assertEquals(HttpMethod.GET.name(), getAttributes(rest).get(HTTP_REQUEST_METHOD.getKey())); // Second span is the gRPC client call Map client = getSpanByKindAndParentId(spans, CLIENT, rest.get("spanId")); @@ -88,8 +88,8 @@ void grpc() { assertEquals("helloworld.Greeter", getAttributes(server).get(RPC_SERVICE.getKey())); assertEquals("SayHello", getAttributes(server).get(RPC_METHOD.getKey())); assertEquals(Status.Code.OK.value(), getAttributes(server).get(RPC_GRPC_STATUS_CODE.getKey())); - assertNotNull(getAttributes(server).get(NET_HOST_NAME.getKey())); - assertNotNull(getAttributes(server).get(NET_HOST_PORT.getKey())); + assertNotNull(getAttributes(server).get(SERVER_ADDRESS.getKey())); + assertNotNull(getAttributes(server).get(SERVER_PORT.getKey())); assertEquals(server.get("parentSpanId"), client.get("spanId")); } diff --git a/integration-tests/opentelemetry-reactive-messaging/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java b/integration-tests/opentelemetry-reactive-messaging/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java index 69adc297df4ba..04c6c96932108 100644 --- a/integration-tests/opentelemetry-reactive-messaging/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java +++ b/integration-tests/opentelemetry-reactive-messaging/src/test/java/io/quarkus/it/opentelemetry/OpenTelemetryTestCase.java @@ -1,6 +1,6 @@ package io.quarkus.it.opentelemetry; -import static io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation.PUBLISH; +import static io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation.PUBLISH; import static io.restassured.RestAssured.get; import static io.restassured.RestAssured.given; import static java.util.concurrent.TimeUnit.SECONDS; @@ -119,13 +119,13 @@ private void verifyServer(Map spanData, Map pare Assertions.assertTrue((Boolean) spanData.get("ended")); Assertions.assertFalse((Boolean) spanData.get("parent_remote")); - Assertions.assertEquals("GET", spanData.get("attr_http.method")); - Assertions.assertEquals("/direct", spanData.get("attr_http.target")); - assertEquals(url.getHost(), spanData.get("attr_net.host.name")); - assertEquals(url.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - Assertions.assertEquals("http", spanData.get("attr_http.scheme")); - Assertions.assertEquals("200", spanData.get("attr_http.status_code")); - Assertions.assertNotNull(spanData.get("attr_http.client_ip")); + Assertions.assertEquals("GET", spanData.get("attr_http.request.method")); + Assertions.assertEquals("/direct", spanData.get("attr_url.path")); + assertEquals(url.getHost(), spanData.get("attr_server.address")); + assertEquals(url.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + Assertions.assertEquals("http", spanData.get("attr_url.scheme")); + Assertions.assertEquals("200", spanData.get("attr_http.response.status_code")); + Assertions.assertNotNull(spanData.get("attr_client.address")); Assertions.assertNotNull(spanData.get("attr_user_agent.original")); } @@ -163,7 +163,7 @@ private static void verifyConsumer(Map spanData, Assertions.assertEquals(topic, spanData.get("attr_messaging.destination.name")); Assertions.assertEquals("opentelemetry-integration-test", spanData.get("attr_messaging.kafka.consumer.group")); Assertions.assertEquals("0", spanData.get("attr_messaging.kafka.partition")); - Assertions.assertEquals("kafka-consumer-" + channel, spanData.get("attr_messaging.kafka.client_id")); + Assertions.assertEquals("kafka-consumer-" + channel, spanData.get("attr_messaging.client_id")); Assertions.assertEquals("0", spanData.get("attr_messaging.kafka.message.offset")); } diff --git a/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/EndUserResource.java b/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/EndUserResource.java index ea8765c35c87e..9b869e34cb154 100644 --- a/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/EndUserResource.java +++ b/integration-tests/opentelemetry-reactive/src/main/java/io/quarkus/it/opentelemetry/reactive/EndUserResource.java @@ -1,5 +1,7 @@ package io.quarkus.it.opentelemetry.reactive; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; + import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.RolesAllowed; import jakarta.inject.Inject; @@ -7,7 +9,6 @@ import jakarta.ws.rs.Path; import io.opentelemetry.api.trace.Tracer; -import io.opentelemetry.semconv.SemanticAttributes; @Path("/otel/enduser") public class EndUserResource { @@ -103,7 +104,7 @@ public String customSpanReaderRole() { var span = tracer.spanBuilder("custom-span").startSpan(); try (var ignored = span.makeCurrent()) { span.setAttribute("custom_attribute", "custom-value"); - span.setAttribute(SemanticAttributes.HTTP_TARGET, "custom-path"); + span.setAttribute(URL_PATH, "custom-path"); } finally { span.end(); } 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 a2c01974d6715..39f136cbf2050 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 @@ -3,10 +3,11 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.INTERNAL; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_TARGET; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; +import static io.opentelemetry.semconv.UrlAttributes.URL_QUERY; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpanByKindAndParentId; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpans; import static io.restassured.RestAssured.given; @@ -58,8 +59,8 @@ void get() { Map client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(SpanKind.CLIENT.toString(), client.get("kind")); assertEquals("GET /reactive", client.get("name")); - assertEquals(HTTP_OK, ((Map) client.get("attributes")).get(HTTP_STATUS_CODE.getKey())); - assertEquals(HttpMethod.GET.name(), ((Map) client.get("attributes")).get(HTTP_METHOD.getKey())); + assertEquals(HTTP_OK, ((Map) client.get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.getKey())); + assertEquals(HttpMethod.GET.name(), ((Map) client.get("attributes")).get(HTTP_REQUEST_METHOD.getKey())); // We should get one server span, from the client call. The client is the parent. Map server = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); @@ -67,9 +68,10 @@ void get() { assertEquals(server.get("parentSpanId"), client.get("spanId")); assertEquals("GET /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())); - assertEquals(HttpMethod.GET.name(), ((Map) server.get("attributes")).get(HTTP_METHOD.getKey())); + assertEquals("/reactive", ((Map) server.get("attributes")).get(URL_PATH.getKey())); + assertEquals("name=Naruto", ((Map) server.get("attributes")).get(URL_QUERY.getKey())); + assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.getKey())); + assertEquals(HttpMethod.GET.name(), ((Map) server.get("attributes")).get(HTTP_REQUEST_METHOD.getKey())); // Final span is an internal one, created by the resource method call. The server is the parent Map internal = getSpanByKindAndParentId(spans, INTERNAL, server.get("spanId")); @@ -93,8 +95,8 @@ void post() { Map client = getSpanByKindAndParentId(spans, CLIENT, "0000000000000000"); assertEquals(SpanKind.CLIENT.toString(), client.get("kind")); assertEquals("POST /reactive", client.get("name")); - assertEquals(HTTP_OK, ((Map) client.get("attributes")).get(HTTP_STATUS_CODE.getKey())); - assertEquals(HttpMethod.POST.name(), ((Map) client.get("attributes")).get(HTTP_METHOD.getKey())); + assertEquals(HTTP_OK, ((Map) client.get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.getKey())); + assertEquals(HttpMethod.POST.name(), ((Map) client.get("attributes")).get(HTTP_REQUEST_METHOD.getKey())); // We should get one server span, from the client call. The client is the parent. Map server = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); @@ -102,9 +104,9 @@ void post() { assertEquals(server.get("parentSpanId"), client.get("spanId")); assertEquals("POST /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())); - assertEquals(HttpMethod.POST.name(), ((Map) server.get("attributes")).get(HTTP_METHOD.getKey())); + assertEquals("/reactive", ((Map) server.get("attributes")).get(URL_PATH.getKey())); + assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.getKey())); + assertEquals(HttpMethod.POST.name(), ((Map) server.get("attributes")).get(HTTP_REQUEST_METHOD.getKey())); // Final span is an internal one, created by the resource method call. The server is the parent Map internal = getSpanByKindAndParentId(spans, INTERNAL, server.get("spanId")); diff --git a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java index c4f3cd0bedd26..193ee7dfaa66b 100644 --- a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java +++ b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/OpenTelemetryReactiveTest.java @@ -3,8 +3,9 @@ import static io.opentelemetry.api.trace.SpanKind.CLIENT; import static io.opentelemetry.api.trace.SpanKind.INTERNAL; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_TARGET; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_URL; +import static io.opentelemetry.semconv.UrlAttributes.URL_FULL; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; +import static io.opentelemetry.semconv.UrlAttributes.URL_QUERY; import static io.quarkus.it.opentelemetry.reactive.Utils.getExceptionEventData; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpanByKindAndParentId; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpanEventAttrs; @@ -169,25 +170,27 @@ void multipleUsingChain() { // Naruto Span Optional> narutoSpan = clientSpans.stream() - .filter(map -> ((String) ((Map) map.get("attributes")).get(HTTP_URL.getKey())).contains("Naruto")) + .filter(map -> ((String) ((Map) map.get("attributes")).get(URL_FULL.getKey())).contains("Naruto")) .findFirst(); assertTrue(narutoSpan.isPresent()); Map naruto = narutoSpan.get(); Map narutoServer = getSpanByKindAndParentId(spans, SERVER, naruto.get("spanId")); - assertEquals("/reactive?name=Naruto", ((Map) narutoServer.get("attributes")).get(HTTP_TARGET.getKey())); + assertEquals("/reactive", ((Map) narutoServer.get("attributes")).get(URL_PATH.getKey())); + assertEquals("name=Naruto", ((Map) narutoServer.get("attributes")).get(URL_QUERY.getKey())); Map narutoInternal = getSpanByKindAndParentId(spans, INTERNAL, narutoServer.get("spanId")); assertEquals("helloGet", narutoInternal.get("name")); // Goku Span Optional> gokuSpan = clientSpans.stream() - .filter(map -> ((String) ((Map) map.get("attributes")).get(HTTP_URL.getKey())).contains("Goku")) + .filter(map -> ((String) ((Map) map.get("attributes")).get(URL_FULL.getKey())).contains("Goku")) .findFirst(); assertTrue(gokuSpan.isPresent()); Map goku = gokuSpan.get(); Map gokuServer = getSpanByKindAndParentId(spans, SERVER, goku.get("spanId")); - assertEquals("/reactive?name=Goku", ((Map) gokuServer.get("attributes")).get(HTTP_TARGET.getKey())); + assertEquals("/reactive", ((Map) gokuServer.get("attributes")).get(URL_PATH.getKey())); + assertEquals("name=Goku", ((Map) gokuServer.get("attributes")).get(URL_QUERY.getKey())); Map gokuInternal = getSpanByKindAndParentId(spans, INTERNAL, gokuServer.get("spanId")); assertEquals("helloGet", gokuInternal.get("name")); } @@ -218,25 +221,27 @@ void multipleUsingCombine() { // Naruto Span Optional> narutoSpan = clientSpans.stream() - .filter(map -> ((String) ((Map) map.get("attributes")).get(HTTP_URL.getKey())).contains("Naruto")) + .filter(map -> ((String) ((Map) map.get("attributes")).get(URL_FULL.getKey())).contains("Naruto")) .findFirst(); assertTrue(narutoSpan.isPresent()); Map naruto = narutoSpan.get(); Map narutoServer = getSpanByKindAndParentId(spans, SERVER, naruto.get("spanId")); - assertEquals("/reactive?name=Naruto", ((Map) narutoServer.get("attributes")).get(HTTP_TARGET.getKey())); + assertEquals("/reactive", ((Map) narutoServer.get("attributes")).get(URL_PATH.getKey())); + assertEquals("name=Naruto", ((Map) narutoServer.get("attributes")).get(URL_QUERY.getKey())); Map narutoInternal = getSpanByKindAndParentId(spans, INTERNAL, narutoServer.get("spanId")); assertEquals("helloGet", narutoInternal.get("name")); // Goku Span Optional> gokuSpan = clientSpans.stream() - .filter(map -> ((String) ((Map) map.get("attributes")).get(HTTP_URL.getKey())).contains("Goku")) + .filter(map -> ((String) ((Map) map.get("attributes")).get(URL_FULL.getKey())).contains("Goku")) .findFirst(); assertTrue(gokuSpan.isPresent()); Map goku = gokuSpan.get(); Map gokuServer = getSpanByKindAndParentId(spans, SERVER, goku.get("spanId")); - assertEquals("/reactive?name=Goku", ((Map) gokuServer.get("attributes")).get(HTTP_TARGET.getKey())); + assertEquals("/reactive", ((Map) gokuServer.get("attributes")).get(URL_PATH.getKey())); + assertEquals("name=Goku", ((Map) gokuServer.get("attributes")).get(URL_QUERY.getKey())); Map gokuInternal = getSpanByKindAndParentId(spans, INTERNAL, gokuServer.get("spanId")); assertEquals("helloGet", gokuInternal.get("name")); } diff --git a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/enduser/AbstractEndUserTest.java b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/enduser/AbstractEndUserTest.java index 841ab567c1b2d..4eef0f49df4e6 100644 --- a/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/enduser/AbstractEndUserTest.java +++ b/integration-tests/opentelemetry-reactive/src/test/java/io/quarkus/it/opentelemetry/reactive/enduser/AbstractEndUserTest.java @@ -1,5 +1,6 @@ package io.quarkus.it.opentelemetry.reactive.enduser; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; import static io.quarkus.it.opentelemetry.reactive.Utils.getSpans; import static io.restassured.RestAssured.get; import static io.restassured.RestAssured.given; @@ -403,7 +404,7 @@ private static Map getSpanByPath(final String path) { return getSpans() .stream() .map(m -> (Map) m.get("attributes")) - .filter(m -> path.equals(m.get(SemanticAttributes.HTTP_TARGET.getKey()))) + .filter(m -> path.equals(m.get(URL_PATH.getKey()))) .findFirst() .orElse(Map.of()); } @@ -421,7 +422,7 @@ protected boolean matchesSafely(Boolean aBoolean) { @Override public void describeTo(Description description) { - description.appendText("Span with the 'http.target' attribute not found: " + path + " ; " + getSpans()); + description.appendText("Span with the 'url.path' attribute not found: " + path + " ; " + getSpans()); } }); return getSpanByPath(path); diff --git a/integration-tests/opentelemetry-spi/src/main/java/io/quarkus/it/opentelemetry/spi/CustomSPISampler.java b/integration-tests/opentelemetry-spi/src/main/java/io/quarkus/it/opentelemetry/spi/CustomSPISampler.java index 3d6f47cc55932..2fca4fb5c1e28 100644 --- a/integration-tests/opentelemetry-spi/src/main/java/io/quarkus/it/opentelemetry/spi/CustomSPISampler.java +++ b/integration-tests/opentelemetry-spi/src/main/java/io/quarkus/it/opentelemetry/spi/CustomSPISampler.java @@ -1,5 +1,7 @@ package io.quarkus.it.opentelemetry.spi; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; + import java.util.List; import io.opentelemetry.api.common.Attributes; @@ -8,7 +10,6 @@ import io.opentelemetry.sdk.trace.data.LinkData; import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingResult; -import io.opentelemetry.semconv.SemanticAttributes; public class CustomSPISampler implements Sampler { @Override @@ -18,7 +19,7 @@ public SamplingResult shouldSample(Context context, SpanKind spanKind, Attributes attributes, List list) { - if (attributes.get(SemanticAttributes.HTTP_TARGET).startsWith("/param/")) { + if (attributes.get(URL_PATH).startsWith("/param/")) { return SamplingResult.drop(); } return Sampler.alwaysOn().shouldSample(context, s, s1, spanKind, attributes, list); diff --git a/integration-tests/opentelemetry-spi/src/test/java/io/quarkus/it/opentelemetry/spi/OTelSpiTest.java b/integration-tests/opentelemetry-spi/src/test/java/io/quarkus/it/opentelemetry/spi/OTelSpiTest.java index 5bd3ac48db163..94e7cb3fd6428 100644 --- a/integration-tests/opentelemetry-spi/src/test/java/io/quarkus/it/opentelemetry/spi/OTelSpiTest.java +++ b/integration-tests/opentelemetry-spi/src/test/java/io/quarkus/it/opentelemetry/spi/OTelSpiTest.java @@ -67,13 +67,13 @@ void testResourceTracing() { assertFalse((Boolean) spanData.get("parent_valid")); assertFalse((Boolean) spanData.get("parent_remote")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/direct", spanData.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/direct", spanData.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java index d3f0968c8f997..59ffefa6a4cf6 100644 --- a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java @@ -85,7 +85,7 @@ private void verifyTraces() { assertThat(span.getAttributesList()) .contains( KeyValue.newBuilder() - .setKey("http.method") + .setKey("http.request.method") .setValue(AnyValue.newBuilder() .setStringValue("GET").build()) .build()); 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 7069126936f96..e54ffda114384 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 @@ -3,11 +3,11 @@ import static io.opentelemetry.api.trace.SpanKind.CONSUMER; import static io.opentelemetry.api.trace.SpanKind.PRODUCER; import static io.opentelemetry.api.trace.SpanKind.SERVER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_ROUTE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_ROUTE; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_BODY_SIZE; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_BODY_SIZE; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_DESTINATION_NAME; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_OPERATION; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_SYSTEM; @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation; +import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation; import io.quarkus.test.junit.QuarkusTest; import io.restassured.common.mapper.TypeRef; import io.restassured.http.ContentType; @@ -59,8 +59,9 @@ void span() { assertEquals(SERVER.toString(), spans.get(0).get("kind")); assertEquals("GET /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(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.toString())); + assertEquals(HttpMethod.GET.toString(), + ((Map) spans.get(0).get("attributes")).get(HTTP_REQUEST_METHOD.toString())); assertEquals("/hello", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); } @@ -78,8 +79,9 @@ void spanPath() { assertEquals(SERVER.toString(), spans.get(0).get("kind")); assertEquals("GET /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(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.toString())); + assertEquals(HttpMethod.GET.toString(), + ((Map) spans.get(0).get("attributes")).get(HTTP_REQUEST_METHOD.toString())); assertEquals("/hello/:name", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); } @@ -99,11 +101,12 @@ void post() { assertEquals(SERVER.toString(), spans.get(0).get("kind")); assertEquals("POST /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(HTTP_OK, ((Map) spans.get(0).get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.toString())); + assertEquals(HttpMethod.POST.toString(), + ((Map) spans.get(0).get("attributes")).get(HTTP_REQUEST_METHOD.toString())); assertEquals("/hello", ((Map) spans.get(0).get("attributes")).get(HTTP_ROUTE.toString())); - assertEquals(6, ((Map) spans.get(0).get("attributes")).get(HTTP_REQUEST_CONTENT_LENGTH.toString())); - assertEquals(12, ((Map) spans.get(0).get("attributes")).get(HTTP_RESPONSE_CONTENT_LENGTH.toString())); + assertEquals(6, ((Map) spans.get(0).get("attributes")).get(HTTP_REQUEST_BODY_SIZE.toString())); + assertEquals(12, ((Map) spans.get(0).get("attributes")).get(HTTP_RESPONSE_BODY_SIZE.toString())); } @Test @@ -127,8 +130,8 @@ void bus() { Map server = getSpanByKindAndParentId(spans, SERVER, "0000000000000000"); assertEquals(SERVER.toString(), server.get("kind")); - assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_STATUS_CODE.toString())); - assertEquals(HttpMethod.GET.toString(), ((Map) server.get("attributes")).get(HTTP_METHOD.toString())); + assertEquals(HTTP_OK, ((Map) server.get("attributes")).get(HTTP_RESPONSE_STATUS_CODE.toString())); + assertEquals(HttpMethod.GET.toString(), ((Map) server.get("attributes")).get(HTTP_REQUEST_METHOD.toString())); assertEquals("/bus", ((Map) server.get("attributes")).get(HTTP_ROUTE.toString())); Map producer = getSpanByKindAndParentId(spans, PRODUCER, server.get("spanId")); 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 9a66684bcbbf0..99f5edfb3b779 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 @@ -1,11 +1,11 @@ package io.quarkus.it.opentelemetry.vertx; import static io.opentelemetry.api.trace.SpanKind.CLIENT; +import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.DB_CONNECTION_STRING; import static io.opentelemetry.semconv.SemanticAttributes.DB_OPERATION; import static io.opentelemetry.semconv.SemanticAttributes.DB_STATEMENT; import static io.opentelemetry.semconv.SemanticAttributes.DB_USER; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; import static io.restassured.RestAssured.given; import static java.net.HttpURLConnection.HTTP_OK; import static org.awaitility.Awaitility.await; @@ -66,7 +66,7 @@ void sqlClient() { // We cannot rely on the order, we must identify the spans. SpanData tableCreation = inMemorySpanExporter.getFinishedSpanItems().stream() - .filter(sd -> sd.getName().contains("DB Query")).findFirst().orElseThrow(); + .filter(sd -> sd.getName().contains("CREATE TABLE USERS")).findFirst().orElseThrow(); SpanData httpSpan = inMemorySpanExporter.getFinishedSpanItems().stream() .filter(sd -> sd.getName().contains("GET /sqlClient")).findFirst().orElseThrow(); SpanData querySpan = inMemorySpanExporter.getFinishedSpanItems().stream() @@ -77,7 +77,7 @@ void sqlClient() { assertEquals(httpSpan.getSpanId(), querySpan.getParentSpanId()); assertEquals("GET /sqlClient", httpSpan.getName()); - assertEquals(HTTP_OK, httpSpan.getAttributes().get(HTTP_STATUS_CODE)); + assertEquals(HTTP_OK, httpSpan.getAttributes().get(HTTP_RESPONSE_STATUS_CODE)); assertEquals("SELECT USERS", querySpan.getName()); assertEquals(CLIENT, querySpan.getKind()); diff --git a/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/EndUserResource.java b/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/EndUserResource.java index e06ff171b8dfd..985a39ba85b3e 100644 --- a/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/EndUserResource.java +++ b/integration-tests/opentelemetry/src/main/java/io/quarkus/it/opentelemetry/EndUserResource.java @@ -1,5 +1,7 @@ package io.quarkus.it.opentelemetry; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; + import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.RolesAllowed; import jakarta.inject.Inject; @@ -7,7 +9,6 @@ import jakarta.ws.rs.Path; import io.opentelemetry.api.trace.Tracer; -import io.opentelemetry.semconv.SemanticAttributes; @Path("/otel/enduser") public class EndUserResource { @@ -103,7 +104,7 @@ public String customSpanReaderRole() { var span = tracer.spanBuilder("custom-span").startSpan(); try (var ignored = span.makeCurrent()) { span.setAttribute("custom_attribute", "custom-value"); - span.setAttribute(SemanticAttributes.HTTP_TARGET, "custom-path"); + span.setAttribute(URL_PATH, "custom-path"); } finally { span.end(); } diff --git a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java index afb0ebc55ee05..39c94d8685422 100644 --- a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java +++ b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java @@ -1,5 +1,6 @@ package io.quarkus.it.opentelemetry; +import static io.opentelemetry.semconv.UrlAttributes.URL_PATH; import static io.quarkus.it.opentelemetry.AbstractEndUserTest.User.SCOTT; import static io.quarkus.it.opentelemetry.AbstractEndUserTest.User.STUART; import static io.restassured.RestAssured.get; @@ -409,7 +410,7 @@ private static List> getSpans() { private static Map getSpanByPath(final String path) { return getSpans() .stream() - .filter(m -> path.equals(m.get("attr_" + SemanticAttributes.HTTP_TARGET.getKey()))) + .filter(m -> path.equals(m.get("attr_" + URL_PATH.getKey()))) .findFirst() .orElse(Map.of()); } @@ -419,7 +420,7 @@ private static Map waitForSpanWithSubPath(final String subPath) } private static Map waitForSpanWithPath(final String path) { - Awaitility.await().atMost(Duration.ofSeconds(30)).until(() -> !getSpanByPath(path).isEmpty(), new TypeSafeMatcher<>() { + Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> !getSpanByPath(path).isEmpty(), new TypeSafeMatcher<>() { @Override protected boolean matchesSafely(Boolean aBoolean) { return Boolean.TRUE.equals(aBoolean); @@ -427,7 +428,7 @@ protected boolean matchesSafely(Boolean aBoolean) { @Override public void describeTo(Description description) { - description.appendText("Span with the 'http.target' attribute not found: " + path + " ; " + getSpans()); + description.appendText("Span with the 'url.path' attribute not found: " + path + " ; " + getSpans()); } }); return getSpanByPath(path); 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 afe87de653e74..43b8b52daa1b4 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 @@ -103,13 +103,13 @@ void testResourceTracing() { assertFalse((Boolean) spanData.get("parent_valid")); assertFalse((Boolean) spanData.get("parent_remote")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/direct", spanData.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/direct", spanData.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } @@ -137,14 +137,14 @@ void testEmptyClientPath() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/nopath", server.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/nopath", server.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); assertEquals("/nopath", server.get("attr_http.route")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); Map client = getSpanByKindAndParentId(spans, CLIENT, server.get("spanId")); @@ -155,9 +155,9 @@ void testEmptyClientPath() { assertTrue((Boolean) client.get("ended")); assertTrue((Boolean) client.get("parent_valid")); assertFalse((Boolean) client.get("parent_remote")); - assertEquals("GET", client.get("attr_http.method")); - assertEquals("http://localhost:8081", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("GET", client.get("attr_http.request.method")); + assertEquals("http://localhost:8081", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); assertEquals(client.get("parentSpanId"), server.get("spanId")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); @@ -168,14 +168,14 @@ void testEmptyClientPath() { assertTrue((Boolean) clientServer.get("ended")); assertTrue((Boolean) clientServer.get("parent_valid")); assertTrue((Boolean) clientServer.get("parent_remote")); - assertEquals("GET", clientServer.get("attr_http.method")); - assertEquals("/", clientServer.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", clientServer.get("attr_http.scheme")); + assertEquals("GET", clientServer.get("attr_http.request.method")); + assertEquals("/", clientServer.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", clientServer.get("attr_url.scheme")); assertEquals("/", clientServer.get("attr_http.route")); - assertEquals("200", clientServer.get("attr_http.status_code")); - assertNotNull(clientServer.get("attr_http.client_ip")); + assertEquals("200", clientServer.get("attr_http.response.status_code")); + assertNotNull(clientServer.get("attr_client.address")); assertNotNull(clientServer.get("attr_user_agent.original")); assertEquals(clientServer.get("parentSpanId"), client.get("spanId")); } @@ -204,14 +204,14 @@ void testSlashClientPath() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/slashpath", server.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/slashpath", server.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); assertEquals("/slashpath", server.get("attr_http.route")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); Map client = getSpanByKindAndParentId(spans, CLIENT, server.get("spanId")); @@ -221,9 +221,9 @@ void testSlashClientPath() { assertTrue((Boolean) client.get("ended")); assertTrue((Boolean) client.get("parent_valid")); assertFalse((Boolean) client.get("parent_remote")); - assertEquals("GET", client.get("attr_http.method")); - assertEquals("http://localhost:8081/", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("GET", client.get("attr_http.request.method")); + assertEquals("http://localhost:8081/", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); assertEquals(client.get("parentSpanId"), server.get("spanId")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); @@ -234,14 +234,14 @@ void testSlashClientPath() { assertTrue((Boolean) clientServer.get("ended")); assertTrue((Boolean) clientServer.get("parent_valid")); assertTrue((Boolean) clientServer.get("parent_remote")); - assertEquals("GET", clientServer.get("attr_http.method")); - assertEquals("/", clientServer.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", clientServer.get("attr_http.scheme")); + assertEquals("GET", clientServer.get("attr_http.request.method")); + assertEquals("/", clientServer.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", clientServer.get("attr_url.scheme")); assertEquals("/", clientServer.get("attr_http.route")); - assertEquals("200", clientServer.get("attr_http.status_code")); - assertNotNull(clientServer.get("attr_http.client_ip")); + assertEquals("200", clientServer.get("attr_http.response.status_code")); + assertNotNull(clientServer.get("attr_client.address")); assertNotNull(clientServer.get("attr_user_agent.original")); assertEquals(clientServer.get("parentSpanId"), client.get("spanId")); } @@ -272,8 +272,8 @@ void testBaggagePath() { Map client = getSpanByKindAndParentId(spans, CLIENT, server.get("spanId")); assertEquals(CLIENT.toString(), client.get("kind")); assertEquals("GET /from-baggage", client.get("name")); - assertEquals("http://localhost:8081/from-baggage", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("http://localhost:8081/from-baggage", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); assertEquals(client.get("parentSpanId"), server.get("spanId")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); @@ -307,13 +307,13 @@ void testChainedResourceTracing() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/chained", server.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/chained", server.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), server.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); // CDI call @@ -362,13 +362,13 @@ void testTracingWithParentHeaders() { assertTrue((Boolean) spanData.get("parent_remote")); assertTrue((Boolean) spanData.get("parent_valid")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/direct", spanData.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/direct", spanData.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } @@ -397,13 +397,13 @@ void testDeepPathNaming() { assertFalse((Boolean) spanData.get("parent_valid")); assertFalse((Boolean) spanData.get("parent_remote")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/deep/path", spanData.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/deep/path", spanData.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } @@ -432,14 +432,14 @@ void testPathParameter() { assertFalse((Boolean) spanData.get("parent_valid")); assertFalse((Boolean) spanData.get("parent_remote")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/param/12345", spanData.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/param/12345", spanData.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); assertEquals("/param/{paramId}", spanData.get("attr_http.route")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } @@ -466,14 +466,14 @@ void testClientTracing() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/client/ping/one", server.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/client/ping/one", server.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); assertEquals("/client/ping/{message}", server.get("attr_http.route")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); Map client = getSpanByKindAndParentId(spans, CLIENT, server.get("spanId")); @@ -482,9 +482,9 @@ void testClientTracing() { assertTrue((Boolean) client.get("ended")); assertTrue((Boolean) client.get("parent_valid")); assertFalse((Boolean) client.get("parent_remote")); - assertEquals("GET", client.get("attr_http.method")); - assertEquals("http://localhost:8081/client/pong/one", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("GET", client.get("attr_http.request.method")); + assertEquals("http://localhost:8081/client/pong/one", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); assertEquals(SERVER.toString(), clientServer.get("kind")); @@ -494,14 +494,14 @@ void testClientTracing() { assertTrue((Boolean) clientServer.get("ended")); assertTrue((Boolean) clientServer.get("parent_valid")); assertTrue((Boolean) clientServer.get("parent_remote")); - assertEquals("GET", clientServer.get("attr_http.method")); - assertEquals("/client/pong/one", clientServer.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", clientServer.get("attr_http.scheme")); + assertEquals("GET", clientServer.get("attr_http.request.method")); + assertEquals("/client/pong/one", clientServer.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", clientServer.get("attr_url.scheme")); assertEquals("/client/pong/{message}", clientServer.get("attr_http.route")); - assertEquals("200", clientServer.get("attr_http.status_code")); - assertNotNull(clientServer.get("attr_http.client_ip")); + assertEquals("200", clientServer.get("attr_http.response.status_code")); + assertNotNull(clientServer.get("attr_client.address")); assertNotNull(clientServer.get("attr_user_agent.original")); assertEquals(clientServer.get("parentSpanId"), client.get("spanId")); } @@ -529,14 +529,14 @@ void testAsyncClientTracing() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/client/async-ping/one", server.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/client/async-ping/one", server.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); assertEquals("/client/async-ping/{message}", server.get("attr_http.route")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); Map client = getSpanByKindAndParentId(spans, CLIENT, server.get("spanId")); @@ -545,9 +545,9 @@ void testAsyncClientTracing() { assertTrue((Boolean) client.get("ended")); assertTrue((Boolean) client.get("parent_valid")); assertFalse((Boolean) client.get("parent_remote")); - assertEquals("GET", client.get("attr_http.method")); - assertEquals("http://localhost:8081/client/pong/one", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("GET", client.get("attr_http.request.method")); + assertEquals("http://localhost:8081/client/pong/one", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); assertEquals(SERVER.toString(), clientServer.get("kind")); @@ -557,14 +557,14 @@ void testAsyncClientTracing() { assertTrue((Boolean) clientServer.get("ended")); assertTrue((Boolean) clientServer.get("parent_valid")); assertTrue((Boolean) clientServer.get("parent_remote")); - assertEquals("GET", clientServer.get("attr_http.method")); - assertEquals("/client/pong/one", clientServer.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", clientServer.get("attr_http.scheme")); + assertEquals("GET", clientServer.get("attr_http.request.method")); + assertEquals("/client/pong/one", clientServer.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", clientServer.get("attr_url.scheme")); assertEquals("/client/pong/{message}", clientServer.get("attr_http.route")); - assertEquals("200", clientServer.get("attr_http.status_code")); - assertNotNull(clientServer.get("attr_http.client_ip")); + assertEquals("200", clientServer.get("attr_http.response.status_code")); + assertNotNull(clientServer.get("attr_client.address")); assertNotNull(clientServer.get("attr_user_agent.original")); } @@ -591,14 +591,14 @@ void testClientTracingWithInterceptor() { assertEquals(TraceId.getInvalid(), server.get("parent_traceId")); assertFalse((Boolean) server.get("parent_valid")); assertFalse((Boolean) server.get("parent_remote")); - assertEquals("GET", server.get("attr_http.method")); - assertEquals("/client/pong-intercept/one", server.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", server.get("attr_http.scheme")); + assertEquals("GET", server.get("attr_http.request.method")); + assertEquals("/client/pong-intercept/one", server.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", server.get("attr_url.scheme")); assertEquals("/client/pong-intercept/{message}", server.get("attr_http.route")); - assertEquals("200", server.get("attr_http.status_code")); - assertNotNull(server.get("attr_http.client_ip")); + assertEquals("200", server.get("attr_http.response.status_code")); + assertNotNull(server.get("attr_client.address")); assertNotNull(server.get("attr_user_agent.original")); Map fromInterceptor = getSpanByKindAndParentId(spans, INTERNAL, server.get("spanId")); @@ -607,8 +607,8 @@ void testClientTracingWithInterceptor() { assertTrue((Boolean) fromInterceptor.get("ended")); assertTrue((Boolean) fromInterceptor.get("parent_valid")); assertFalse((Boolean) fromInterceptor.get("parent_remote")); - assertNull(fromInterceptor.get("attr_http.method")); - assertNull(fromInterceptor.get("attr_http.status_code")); + assertNull(fromInterceptor.get("attr_http.request.method")); + assertNull(fromInterceptor.get("attr_http.response.status_code")); assertEquals("one", fromInterceptor.get("attr_message")); Map client = getSpanByKindAndParentId(spans, CLIENT, fromInterceptor.get("spanId")); @@ -617,9 +617,9 @@ void testClientTracingWithInterceptor() { assertTrue((Boolean) client.get("ended")); assertTrue((Boolean) client.get("parent_valid")); assertFalse((Boolean) client.get("parent_remote")); - assertEquals("GET", client.get("attr_http.method")); - assertEquals("http://localhost:8081/client/pong/one", client.get("attr_http.url")); - assertEquals("200", client.get("attr_http.status_code")); + assertEquals("GET", client.get("attr_http.request.method")); + assertEquals("http://localhost:8081/client/pong/one", client.get("attr_url.full")); + assertEquals("200", client.get("attr_http.response.status_code")); Map clientServer = getSpanByKindAndParentId(spans, SERVER, client.get("spanId")); assertEquals(SERVER.toString(), clientServer.get("kind")); @@ -629,14 +629,14 @@ void testClientTracingWithInterceptor() { assertTrue((Boolean) clientServer.get("ended")); assertTrue((Boolean) clientServer.get("parent_valid")); assertTrue((Boolean) clientServer.get("parent_remote")); - assertEquals("GET", clientServer.get("attr_http.method")); - assertEquals("/client/pong/one", clientServer.get("attr_http.target")); - assertEquals(pathParamUrl.getHost(), server.get("attr_net.host.name")); - assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_net.host.port"))); - assertEquals("http", clientServer.get("attr_http.scheme")); + assertEquals("GET", clientServer.get("attr_http.request.method")); + assertEquals("/client/pong/one", clientServer.get("attr_url.path")); + assertEquals(pathParamUrl.getHost(), server.get("attr_server.address")); + assertEquals(pathParamUrl.getPort(), Integer.valueOf((String) server.get("attr_server.port"))); + assertEquals("http", clientServer.get("attr_url.scheme")); assertEquals("/client/pong/{message}", clientServer.get("attr_http.route")); - assertEquals("200", clientServer.get("attr_http.status_code")); - assertNotNull(clientServer.get("attr_http.client_ip")); + assertEquals("200", clientServer.get("attr_http.response.status_code")); + assertNotNull(clientServer.get("attr_client.address")); assertNotNull(clientServer.get("attr_user_agent.original")); assertEquals(clientServer.get("parentSpanId"), client.get("spanId")); } @@ -666,13 +666,13 @@ void testTemplatedPathOnClass() { assertFalse((Boolean) spanData.get("parent_valid")); assertFalse((Boolean) spanData.get("parent_remote")); - assertEquals("GET", spanData.get("attr_http.method")); - assertEquals("/template/path/something", spanData.get("attr_http.target")); - assertEquals(deepPathUrl.getHost(), spanData.get("attr_net.host.name")); - assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_net.host.port"))); - assertEquals("http", spanData.get("attr_http.scheme")); - assertEquals("200", spanData.get("attr_http.status_code")); - assertNotNull(spanData.get("attr_http.client_ip")); + assertEquals("GET", spanData.get("attr_http.request.method")); + assertEquals("/template/path/something", spanData.get("attr_url.path")); + assertEquals(deepPathUrl.getHost(), spanData.get("attr_server.address")); + assertEquals(deepPathUrl.getPort(), Integer.valueOf((String) spanData.get("attr_server.port"))); + assertEquals("http", spanData.get("attr_url.scheme")); + assertEquals("200", spanData.get("attr_http.response.status_code")); + assertNotNull(spanData.get("attr_client.address")); assertNotNull(spanData.get("attr_user_agent.original")); } diff --git a/integration-tests/rest-client-reactive/src/main/resources/application.properties b/integration-tests/rest-client-reactive/src/main/resources/application.properties index e76e85e297bd1..293b842b23b7f 100644 --- a/integration-tests/rest-client-reactive/src/main/resources/application.properties +++ b/integration-tests/rest-client-reactive/src/main/resources/application.properties @@ -15,3 +15,6 @@ quarkus.rest-client.wrong-host.verify-host=false # Wrong Host client verified (connection rejected, as host verification is turned on by default) quarkus.rest-client.wrong-host-rejected.trust-store=${wrong-host.trust-store} quarkus.rest-client.wrong-host-rejected.trust-store-password=${wrong-host.trust-store-password} + +# speed up build +quarkus.otel.bsp.schedule.delay=100 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 28d67c962a4e1..0dc59698a2444 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 @@ -1,9 +1,11 @@ package io.quarkus.it.rest.client; import static io.restassured.RestAssured.get; +import static io.restassured.RestAssured.given; import static java.util.stream.Collectors.counting; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.equalTo; import java.time.Duration; @@ -147,10 +149,10 @@ void shouldCreateClientSpans() { String serverTraceId = null; String clientSpanId = null; - Awaitility.await().atMost(Duration.ofMinutes(2)) - .until(() -> getServerSpans("POST /call-hello-client-trace", "/call-hello-client-trace").size() > 0); + Awaitility.await().atMost(Duration.ofSeconds(30)) + .until(() -> getServerSpansFromPath("POST /call-hello-client-trace", "/call-hello-client-trace").size() > 0); - List> spans = getServerSpans("POST /call-hello-client-trace", "/call-hello-client-trace"); + List> spans = getServerSpansFromPath("POST /call-hello-client-trace", "/call-hello-client-trace"); Assertions.assertEquals(1, spans.size()); final Map initialServerSpan = spans.get(0); @@ -170,14 +172,17 @@ void shouldCreateClientSpans() { Assertions.assertFalse((Boolean) initialServerSpan.get("parent_valid")); Assertions.assertFalse((Boolean) initialServerSpan.get("parent_remote")); - Assertions.assertEquals("POST", initialServerSpan.get("attr_http.method")); - Assertions.assertEquals("/call-hello-client-trace", initialServerSpan.get("attr_http.target")); - Assertions.assertEquals("http", initialServerSpan.get("attr_http.scheme")); - Assertions.assertEquals("200", initialServerSpan.get("attr_http.status_code")); - Assertions.assertNotNull(initialServerSpan.get("attr_http.client_ip")); + Assertions.assertEquals("POST", initialServerSpan.get("attr_http.request.method")); + Assertions.assertEquals("/call-hello-client-trace", initialServerSpan.get("attr_url.path")); + Assertions.assertEquals("http", initialServerSpan.get("attr_url.scheme")); + Assertions.assertEquals("200", initialServerSpan.get("attr_http.response.status_code")); + Assertions.assertNotNull(initialServerSpan.get("attr_client.address")); Assertions.assertNotNull(initialServerSpan.get("attr_user_agent.original")); - spans = getClientSpans("POST", "http://localhost:8081/hello?count=3"); + Awaitility.await().atMost(Duration.ofSeconds(30)) + .until(() -> getClientSpansFromFullUrl("POST", "http://localhost:8081/hello?count=3").size() > 0); + + spans = getClientSpansFromFullUrl("POST", "http://localhost:8081/hello?count=3"); Assertions.assertEquals(1, spans.size()); final Map clientSpan = spans.get(0); @@ -199,13 +204,15 @@ void shouldCreateClientSpans() { Assertions.assertTrue((Boolean) clientSpan.get("parent_valid")); Assertions.assertFalse((Boolean) clientSpan.get("parent_remote")); - Assertions.assertEquals("POST", clientSpan.get("attr_http.method")); - Assertions.assertEquals("http://localhost:8081/hello?count=3", clientSpan.get("attr_http.url")); - Assertions.assertEquals("200", clientSpan.get("attr_http.status_code")); + Assertions.assertEquals("POST", clientSpan.get("attr_http.request.method")); + Assertions.assertEquals("http://localhost:8081/hello?count=3", clientSpan.get("attr_url.full")); + Assertions.assertEquals("200", clientSpan.get("attr_http.response.status_code")); clientSpanId = (String) clientSpan.get("spanId"); - spans = getServerSpans("POST /hello", "/hello?count=3"); + Awaitility.await().atMost(Duration.ofSeconds(30)) + .until(() -> getServerSpansFromPath("POST /hello", "/hello").size() > 0); + spans = getServerSpansFromPath("POST /hello", "/hello"); Assertions.assertEquals(1, spans.size()); final Map serverSpanClientSide = spans.get(0); @@ -226,11 +233,12 @@ void shouldCreateClientSpans() { Assertions.assertTrue((Boolean) serverSpanClientSide.get("parent_valid")); Assertions.assertTrue((Boolean) serverSpanClientSide.get("parent_remote")); - Assertions.assertEquals("POST", serverSpanClientSide.get("attr_http.method")); - Assertions.assertEquals("/hello?count=3", serverSpanClientSide.get("attr_http.target")); - Assertions.assertEquals("http", serverSpanClientSide.get("attr_http.scheme")); - Assertions.assertEquals("200", serverSpanClientSide.get("attr_http.status_code")); - Assertions.assertNotNull(serverSpanClientSide.get("attr_http.client_ip")); + Assertions.assertEquals("POST", serverSpanClientSide.get("attr_http.request.method")); + Assertions.assertEquals("/hello", serverSpanClientSide.get("attr_url.path")); + Assertions.assertEquals("count=3", serverSpanClientSide.get("attr_url.query")); + Assertions.assertEquals("http", serverSpanClientSide.get("attr_url.scheme")); + Assertions.assertEquals("200", serverSpanClientSide.get("attr_http.response.status_code")); + Assertions.assertNotNull(serverSpanClientSide.get("attr_client.address")); } @Test @@ -241,21 +249,21 @@ public void shouldConvertParamFirstToOneUsingCustomConverter() { .body(equalTo("1")); } - private List> getServerSpans(final String spanName, final String httpTarget) { + private List> getServerSpansFromPath(final String spanName, final String urlPath) { return get("/export").body().as(new TypeRef>>() { }).stream() .filter(stringObjectMap -> spanName.equals(stringObjectMap.get("name")) && "SERVER".equals(stringObjectMap.get("kind")) && - ((String) stringObjectMap.get("attr_http.target")).startsWith(httpTarget)) + ((String) stringObjectMap.get("attr_url.path")).startsWith(urlPath)) .collect(Collectors.toList()); } - private List> getClientSpans(final String spanName, final String httpUrl) { + private List> getClientSpansFromFullUrl(final String spanName, final String httpUrl) { return get("/export").body().as(new TypeRef>>() { }).stream() .filter(stringObjectMap -> spanName.equals(stringObjectMap.get("name")) && "CLIENT".equals(stringObjectMap.get("kind")) && - ((String) stringObjectMap.get("attr_http.url")).startsWith(httpUrl)) + ((String) stringObjectMap.get("attr_url.full")).startsWith(httpUrl)) .collect(Collectors.toList()); } } diff --git a/tcks/pom.xml b/tcks/pom.xml index 284143d1d6786..24e04d682d64a 100644 --- a/tcks/pom.xml +++ b/tcks/pom.xml @@ -116,7 +116,7 @@ microprofile-rest-client microprofile-rest-client-reactive microprofile-openapi - microprofile-opentelemetry + microprofile-lra resteasy-reactive