From ae25d481ff6e9f9496dd25111249311e58cd1bea Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 20 Sep 2023 04:53:40 -0700 Subject: [PATCH] Use new semconv constants (#9504) --- .../http/HttpClientAttributesExtractor.java | 3 +- .../http/HttpCommonAttributesExtractor.java | 13 ++-- .../http/HttpMessageBodySizeUtil.java | 5 +- .../instrumenter/http/HttpMetricsAdvice.java | 55 +++++++------- .../http/internal/HttpAttributes.java | 36 ---------- .../InternalClientAttributesExtractor.java | 8 +-- .../InternalNetworkAttributesExtractor.java | 8 +-- .../InternalServerAttributesExtractor.java | 10 +-- .../network/internal/NetworkAttributes.java | 53 -------------- .../instrumenter/rpc/RpcMetricsAdvice.java | 25 ++++--- .../InternalUrlAttributesExtractor.java | 6 +- .../url/internal/UrlAttributes.java | 30 -------- .../url/UrlAttributesExtractorTest.java | 8 +-- ...entAttributesExtractorBothSemconvTest.java | 25 +++---- ...verAttributesExtractorBothSemconvTest.java | 29 ++++---- ...entAttributesExtractorBothSemconvTest.java | 19 +++-- ...verAttributesExtractorBothSemconvTest.java | 21 +++--- ...tAttributesExtractorStableSemconvTest.java | 49 ++++++------- ...tExperimentalMetricsStableSemconvTest.java | 66 ++++++++--------- .../HttpClientMetricsStableSemconvTest.java | 50 ++++++------- ...rAttributesExtractorStableSemconvTest.java | 53 +++++++------- ...rExperimentalMetricsStableSemconvTest.java | 72 +++++++++---------- .../HttpServerMetricsStableSemconvTest.java | 54 +++++++------- ...tAttributesExtractorStableSemconvTest.java | 20 +++--- ...rAttributesExtractorStableSemconvTest.java | 22 +++--- ...ributesExtractorInetSocketAddressTest.java | 6 +- .../ClientAttributesExtractorTest.java | 14 ++-- .../NetworkAttributesExtractorTest.java | 10 +-- ...ributesExtractorInetSocketAddressTest.java | 8 +-- .../ServerAttributesExtractorTest.java | 20 +++--- .../ApiGatewayProxyAttributesExtractor.java | 12 ++-- .../decorators/HttpSpanDecorator.java | 12 ++-- ...ElasticsearchClientAttributeExtractor.java | 15 ++-- .../HttpMethodAttributeExtractor.java | 9 ++- .../test/groovy/Netty40ClientSslTest.groovy | 42 +++++------ .../groovy/Netty40ConnectionSpanTest.groovy | 22 +++--- .../test/groovy/Netty41ClientSslTest.groovy | 50 ++++++------- .../groovy/Netty41ConnectionSpanTest.groovy | 30 ++++---- .../src/test/groovy/UndertowServerTest.groovy | 56 +++++++-------- .../junit/http/AbstractHttpClientTest.java | 12 ++-- .../junit/http/AbstractHttpServerTest.java | 26 ++++--- .../junit/http/SemconvStabilityUtil.java | 39 +++++----- 42 files changed, 485 insertions(+), 638 deletions(-) delete mode 100644 instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/internal/HttpAttributes.java delete mode 100644 instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/NetworkAttributes.java delete mode 100644 instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/UrlAttributes.java diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractor.java index 03f8c965cb..23efcb6759 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractor.java @@ -13,7 +13,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.internal.InternalNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.internal.InternalServerAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.internal.SpanKey; import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; @@ -109,7 +108,7 @@ public final class HttpClientAttributesExtractor String fullUrl = stripSensitiveData(getter.getUrlFull(request)); if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, UrlAttributes.URL_FULL, fullUrl); + internalSet(attributes, SemanticAttributes.URL_FULL, fullUrl); } if (SemconvStability.emitOldHttpSemconv()) { internalSet(attributes, SemanticAttributes.HTTP_URL, fullUrl); diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesExtractor.java index 926e1f5804..cea9dc1ea5 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesExtractor.java @@ -14,7 +14,6 @@ import static io.opentelemetry.instrumentation.api.internal.HttpConstants._OTHER import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashSet; @@ -53,10 +52,10 @@ abstract class HttpCommonAttributesExtractor< String method = getter.getHttpRequestMethod(request); if (SemconvStability.emitStableHttpSemconv()) { if (method == null || knownMethods.contains(method)) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method); } else { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); } } if (SemconvStability.emitOldHttpSemconv()) { @@ -83,7 +82,7 @@ abstract class HttpCommonAttributesExtractor< Long requestBodySize = requestBodySize(request); if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize); } if (SemconvStability.emitOldHttpSemconv()) { internalSet(attributes, SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, requestBodySize); @@ -93,7 +92,7 @@ abstract class HttpCommonAttributesExtractor< Integer statusCode = getter.getHttpResponseStatusCode(request, response, error); if (statusCode != null && statusCode > 0) { if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, HttpAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode); + internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode); } if (SemconvStability.emitOldHttpSemconv()) { internalSet(attributes, SemanticAttributes.HTTP_STATUS_CODE, (long) statusCode); @@ -102,7 +101,7 @@ abstract class HttpCommonAttributesExtractor< Long responseBodySize = responseBodySize(request, response); if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, HttpAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize); + internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize); } if (SemconvStability.emitOldHttpSemconv()) { internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, responseBodySize); diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMessageBodySizeUtil.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMessageBodySizeUtil.java index b739cad60e..15d8d38a9f 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMessageBodySizeUtil.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMessageBodySizeUtil.java @@ -7,7 +7,6 @@ package io.opentelemetry.instrumentation.api.instrumenter.http; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.SemanticAttributes; import javax.annotation.Nullable; @@ -18,13 +17,13 @@ final class HttpMessageBodySizeUtil { private static final AttributeKey HTTP_REQUEST_BODY_SIZE = SemconvStability.emitOldHttpSemconv() ? SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH - : HttpAttributes.HTTP_REQUEST_BODY_SIZE; + : SemanticAttributes.HTTP_REQUEST_BODY_SIZE; @SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0 private static final AttributeKey HTTP_RESPONSE_BODY_SIZE = SemconvStability.emitOldHttpSemconv() ? SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH - : HttpAttributes.HTTP_RESPONSE_BODY_SIZE; + : SemanticAttributes.HTTP_RESPONSE_BODY_SIZE; @Nullable static Long getHttpRequestBodySize(Attributes... attributesList) { diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMetricsAdvice.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMetricsAdvice.java index e18a3e87e9..032801d898 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMetricsAdvice.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMetricsAdvice.java @@ -13,9 +13,6 @@ import io.opentelemetry.api.metrics.LongUpDownCounterBuilder; import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder; import io.opentelemetry.extension.incubator.metrics.ExtendedLongHistogramBuilder; import io.opentelemetry.extension.incubator.metrics.ExtendedLongUpDownCounterBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.semconv.SemanticAttributes; final class HttpMetricsAdvice { @@ -29,13 +26,13 @@ final class HttpMetricsAdvice { advice -> advice.setAttributes( asList( - HttpAttributes.HTTP_REQUEST_METHOD, - HttpAttributes.HTTP_RESPONSE_STATUS_CODE, - NetworkAttributes.NETWORK_PROTOCOL_NAME, - NetworkAttributes.NETWORK_PROTOCOL_VERSION, - NetworkAttributes.SERVER_ADDRESS, - NetworkAttributes.SERVER_PORT, - NetworkAttributes.SERVER_SOCKET_ADDRESS))); + SemanticAttributes.HTTP_REQUEST_METHOD, + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, + SemanticAttributes.NETWORK_PROTOCOL_NAME, + SemanticAttributes.NETWORK_PROTOCOL_VERSION, + SemanticAttributes.SERVER_ADDRESS, + SemanticAttributes.SERVER_PORT, + SemanticAttributes.SERVER_SOCKET_ADDRESS))); } @SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0 @@ -68,13 +65,13 @@ final class HttpMetricsAdvice { advice.setAttributes( asList( // stable attributes - HttpAttributes.HTTP_REQUEST_METHOD, - HttpAttributes.HTTP_RESPONSE_STATUS_CODE, - NetworkAttributes.NETWORK_PROTOCOL_NAME, - NetworkAttributes.NETWORK_PROTOCOL_VERSION, - NetworkAttributes.SERVER_ADDRESS, - NetworkAttributes.SERVER_PORT, - NetworkAttributes.SERVER_SOCKET_ADDRESS, + SemanticAttributes.HTTP_REQUEST_METHOD, + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, + SemanticAttributes.NETWORK_PROTOCOL_NAME, + SemanticAttributes.NETWORK_PROTOCOL_VERSION, + SemanticAttributes.SERVER_ADDRESS, + SemanticAttributes.SERVER_PORT, + SemanticAttributes.SERVER_SOCKET_ADDRESS, // old attributes SemanticAttributes.HTTP_METHOD, SemanticAttributes.HTTP_STATUS_CODE, @@ -95,11 +92,11 @@ final class HttpMetricsAdvice { advice.setAttributes( asList( SemanticAttributes.HTTP_ROUTE, - HttpAttributes.HTTP_REQUEST_METHOD, - HttpAttributes.HTTP_RESPONSE_STATUS_CODE, - NetworkAttributes.NETWORK_PROTOCOL_NAME, - NetworkAttributes.NETWORK_PROTOCOL_VERSION, - UrlAttributes.URL_SCHEME))); + SemanticAttributes.HTTP_REQUEST_METHOD, + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, + SemanticAttributes.NETWORK_PROTOCOL_NAME, + SemanticAttributes.NETWORK_PROTOCOL_VERSION, + SemanticAttributes.URL_SCHEME))); } @SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0 @@ -134,11 +131,11 @@ final class HttpMetricsAdvice { asList( // stable attributes SemanticAttributes.HTTP_ROUTE, - HttpAttributes.HTTP_REQUEST_METHOD, - HttpAttributes.HTTP_RESPONSE_STATUS_CODE, - NetworkAttributes.NETWORK_PROTOCOL_NAME, - NetworkAttributes.NETWORK_PROTOCOL_VERSION, - UrlAttributes.URL_SCHEME, + SemanticAttributes.HTTP_REQUEST_METHOD, + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, + SemanticAttributes.NETWORK_PROTOCOL_NAME, + SemanticAttributes.NETWORK_PROTOCOL_VERSION, + SemanticAttributes.URL_SCHEME, // old attributes SemanticAttributes.HTTP_SCHEME, SemanticAttributes.HTTP_ROUTE, @@ -166,8 +163,8 @@ final class HttpMetricsAdvice { SemanticAttributes.NET_HOST_NAME, SemanticAttributes.NET_HOST_PORT, // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md#metric-httpserveractive_requests - HttpAttributes.HTTP_REQUEST_METHOD, - UrlAttributes.URL_SCHEME))); + SemanticAttributes.HTTP_REQUEST_METHOD, + SemanticAttributes.URL_SCHEME))); } private HttpMetricsAdvice() {} diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/internal/HttpAttributes.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/internal/HttpAttributes.java deleted file mode 100644 index 9de03953d3..0000000000 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/internal/HttpAttributes.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter.http.internal; - -import static io.opentelemetry.api.common.AttributeKey.longKey; -import static io.opentelemetry.api.common.AttributeKey.stringKey; - -import io.opentelemetry.api.common.AttributeKey; - -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public final class HttpAttributes { - - // FIXME: remove this class and replace its usages with SemanticAttributes once schema 1.21 is - // released - - public static final AttributeKey HTTP_REQUEST_METHOD = stringKey("http.request.method"); - - public static final AttributeKey HTTP_REQUEST_METHOD_ORIGINAL = - stringKey("http.request.method_original"); - - public static final AttributeKey HTTP_REQUEST_BODY_SIZE = longKey("http.request.body.size"); - - public static final AttributeKey HTTP_RESPONSE_BODY_SIZE = - longKey("http.response.body.size"); - - public static final AttributeKey HTTP_RESPONSE_STATUS_CODE = - longKey("http.response.status_code"); - - private HttpAttributes() {} -} diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalClientAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalClientAttributesExtractor.java index c96f2e653d..1a39f7c221 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalClientAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalClientAttributesExtractor.java @@ -39,9 +39,9 @@ public final class InternalClientAttributesExtractor { AddressAndPort clientAddressAndPort = extractClientAddressAndPort(request); if (emitStableUrlAttributes) { - internalSet(attributes, NetworkAttributes.CLIENT_ADDRESS, clientAddressAndPort.address); + internalSet(attributes, SemanticAttributes.CLIENT_ADDRESS, clientAddressAndPort.address); if (clientAddressAndPort.port != null && clientAddressAndPort.port > 0) { - internalSet(attributes, NetworkAttributes.CLIENT_PORT, (long) clientAddressAndPort.port); + internalSet(attributes, SemanticAttributes.CLIENT_PORT, (long) clientAddressAndPort.port); } } if (emitOldHttpAttributes) { @@ -57,7 +57,7 @@ public final class InternalClientAttributesExtractor { if (clientSocketAddress != null && !clientSocketAddress.equals(clientAddressAndPort.address)) { if (emitStableUrlAttributes) { - internalSet(attributes, NetworkAttributes.CLIENT_SOCKET_ADDRESS, clientSocketAddress); + internalSet(attributes, SemanticAttributes.CLIENT_SOCKET_ADDRESS, clientSocketAddress); } if (emitOldHttpAttributes) { internalSet(attributes, SemanticAttributes.NET_SOCK_PEER_ADDR, clientSocketAddress); @@ -66,7 +66,7 @@ public final class InternalClientAttributesExtractor { if (clientSocketPort != null && clientSocketPort > 0) { if (emitStableUrlAttributes) { if (!clientSocketPort.equals(clientAddressAndPort.port)) { - internalSet(attributes, NetworkAttributes.CLIENT_SOCKET_PORT, (long) clientSocketPort); + internalSet(attributes, SemanticAttributes.CLIENT_SOCKET_PORT, (long) clientSocketPort); } } if (emitOldHttpAttributes) { diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalNetworkAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalNetworkAttributesExtractor.java index cfd2a74887..3a43fd3c9e 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalNetworkAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalNetworkAttributesExtractor.java @@ -44,14 +44,14 @@ public final class InternalNetworkAttributesExtractor { String transport = lowercase(getter.getNetworkTransport(request, response)); if (networkTransportFilter.shouldAddNetworkTransport( protocolName, protocolVersion, transport)) { - internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport); + internalSet(attributes, SemanticAttributes.NETWORK_TRANSPORT, transport); } internalSet( attributes, - NetworkAttributes.NETWORK_TYPE, + SemanticAttributes.NETWORK_TYPE, lowercase(getter.getNetworkType(request, response))); - internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName); - internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion); + internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_NAME, protocolName); + internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion); } if (emitOldHttpAttributes) { // net.transport and net.sock.family are not 1:1 convertible with network.transport and diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalServerAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalServerAttributesExtractor.java index 60cf2590ee..b00fd5c7f5 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalServerAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalServerAttributesExtractor.java @@ -49,7 +49,7 @@ public final class InternalServerAttributesExtractor { AddressAndPort serverAddressAndPort = extractServerAddressAndPort(request); if (emitStableUrlAttributes) { - internalSet(attributes, NetworkAttributes.SERVER_ADDRESS, serverAddressAndPort.address); + internalSet(attributes, SemanticAttributes.SERVER_ADDRESS, serverAddressAndPort.address); } if (emitOldHttpAttributes) { internalSet(attributes, oldSemconvMode.address, serverAddressAndPort.address); @@ -59,7 +59,7 @@ public final class InternalServerAttributesExtractor { && serverAddressAndPort.port > 0 && captureServerPortCondition.test(serverAddressAndPort.port, request)) { if (emitStableUrlAttributes) { - internalSet(attributes, NetworkAttributes.SERVER_PORT, (long) serverAddressAndPort.port); + internalSet(attributes, SemanticAttributes.SERVER_PORT, (long) serverAddressAndPort.port); } if (emitOldHttpAttributes) { internalSet(attributes, oldSemconvMode.port, (long) serverAddressAndPort.port); @@ -73,7 +73,7 @@ public final class InternalServerAttributesExtractor { String serverSocketAddress = getter.getServerSocketAddress(request, response); if (serverSocketAddress != null && !serverSocketAddress.equals(serverAddressAndPort.address)) { if (emitStableUrlAttributes && captureServerSocketAttributes) { - internalSet(attributes, NetworkAttributes.SERVER_SOCKET_ADDRESS, serverSocketAddress); + internalSet(attributes, SemanticAttributes.SERVER_SOCKET_ADDRESS, serverSocketAddress); } if (emitOldHttpAttributes) { internalSet(attributes, oldSemconvMode.socketAddress, serverSocketAddress); @@ -85,7 +85,7 @@ public final class InternalServerAttributesExtractor { && serverSocketPort > 0 && !serverSocketPort.equals(serverAddressAndPort.port)) { if (emitStableUrlAttributes && captureServerSocketAttributes) { - internalSet(attributes, NetworkAttributes.SERVER_SOCKET_PORT, (long) serverSocketPort); + internalSet(attributes, SemanticAttributes.SERVER_SOCKET_PORT, (long) serverSocketPort); } if (emitOldHttpAttributes) { internalSet(attributes, oldSemconvMode.socketPort, (long) serverSocketPort); @@ -95,7 +95,7 @@ public final class InternalServerAttributesExtractor { String serverSocketDomain = getter.getServerSocketDomain(request, response); if (serverSocketDomain != null && !serverSocketDomain.equals(serverAddressAndPort.address)) { if (emitStableUrlAttributes && captureServerSocketAttributes) { - internalSet(attributes, NetworkAttributes.SERVER_SOCKET_DOMAIN, serverSocketDomain); + internalSet(attributes, SemanticAttributes.SERVER_SOCKET_DOMAIN, serverSocketDomain); } if (emitOldHttpAttributes && oldSemconvMode.socketDomain != null) { internalSet(attributes, oldSemconvMode.socketDomain, serverSocketDomain); diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/NetworkAttributes.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/NetworkAttributes.java deleted file mode 100644 index 1d8c57a30c..0000000000 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/NetworkAttributes.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter.network.internal; - -import static io.opentelemetry.api.common.AttributeKey.longKey; -import static io.opentelemetry.api.common.AttributeKey.stringKey; - -import io.opentelemetry.api.common.AttributeKey; - -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public final class NetworkAttributes { - - // FIXME: remove this class and replace its usages with SemanticAttributes once schema 1.20 is - // released - - public static final AttributeKey NETWORK_TRANSPORT = stringKey("network.transport"); - - public static final AttributeKey NETWORK_TYPE = stringKey("network.type"); - - public static final AttributeKey NETWORK_PROTOCOL_NAME = - stringKey("network.protocol.name"); - - public static final AttributeKey NETWORK_PROTOCOL_VERSION = - stringKey("network.protocol.version"); - - public static final AttributeKey SERVER_ADDRESS = stringKey("server.address"); - - public static final AttributeKey SERVER_PORT = longKey("server.port"); - - public static final AttributeKey SERVER_SOCKET_DOMAIN = stringKey("server.socket.domain"); - - public static final AttributeKey SERVER_SOCKET_ADDRESS = - stringKey("server.socket.address"); - - public static final AttributeKey SERVER_SOCKET_PORT = longKey("server.socket.port"); - - public static final AttributeKey CLIENT_ADDRESS = stringKey("client.address"); - - public static final AttributeKey CLIENT_PORT = longKey("client.port"); - - public static final AttributeKey CLIENT_SOCKET_ADDRESS = - stringKey("client.socket.address"); - - public static final AttributeKey CLIENT_SOCKET_PORT = longKey("client.socket.port"); - - private NetworkAttributes() {} -} diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcMetricsAdvice.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcMetricsAdvice.java index 856938aa84..1803655981 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcMetricsAdvice.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcMetricsAdvice.java @@ -8,7 +8,6 @@ package io.opentelemetry.instrumentation.api.instrumenter.rpc; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.metrics.DoubleHistogramBuilder; import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.SemanticAttributes; import java.util.ArrayList; @@ -31,12 +30,12 @@ final class RpcMetricsAdvice { attributes.add(SemanticAttributes.RPC_METHOD); attributes.add(SemanticAttributes.RPC_GRPC_STATUS_CODE); if (SemconvStability.emitStableHttpSemconv()) { - attributes.add(NetworkAttributes.NETWORK_TYPE); - attributes.add(NetworkAttributes.NETWORK_TRANSPORT); - attributes.add(NetworkAttributes.SERVER_ADDRESS); - attributes.add(NetworkAttributes.SERVER_PORT); - attributes.add(NetworkAttributes.SERVER_SOCKET_ADDRESS); - attributes.add(NetworkAttributes.SERVER_SOCKET_PORT); + attributes.add(SemanticAttributes.NETWORK_TYPE); + attributes.add(SemanticAttributes.NETWORK_TRANSPORT); + attributes.add(SemanticAttributes.SERVER_ADDRESS); + attributes.add(SemanticAttributes.SERVER_PORT); + attributes.add(SemanticAttributes.SERVER_SOCKET_ADDRESS); + attributes.add(SemanticAttributes.SERVER_SOCKET_PORT); } if (SemconvStability.emitOldHttpSemconv()) { attributes.add(SemanticAttributes.NET_PEER_NAME); @@ -63,12 +62,12 @@ final class RpcMetricsAdvice { attributes.add(SemanticAttributes.RPC_METHOD); attributes.add(SemanticAttributes.RPC_GRPC_STATUS_CODE); if (SemconvStability.emitStableHttpSemconv()) { - attributes.add(NetworkAttributes.NETWORK_TYPE); - attributes.add(NetworkAttributes.NETWORK_TRANSPORT); - attributes.add(NetworkAttributes.SERVER_ADDRESS); - attributes.add(NetworkAttributes.SERVER_PORT); - attributes.add(NetworkAttributes.SERVER_SOCKET_ADDRESS); - attributes.add(NetworkAttributes.SERVER_SOCKET_PORT); + attributes.add(SemanticAttributes.NETWORK_TYPE); + attributes.add(SemanticAttributes.NETWORK_TRANSPORT); + attributes.add(SemanticAttributes.SERVER_ADDRESS); + attributes.add(SemanticAttributes.SERVER_PORT); + attributes.add(SemanticAttributes.SERVER_SOCKET_ADDRESS); + attributes.add(SemanticAttributes.SERVER_SOCKET_PORT); } if (SemconvStability.emitOldHttpSemconv()) { attributes.add(SemanticAttributes.NET_HOST_NAME); diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/InternalUrlAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/InternalUrlAttributesExtractor.java index 018e5eb1b8..ace4bd8d11 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/InternalUrlAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/InternalUrlAttributesExtractor.java @@ -42,9 +42,9 @@ public final class InternalUrlAttributesExtractor { String urlQuery = getter.getUrlQuery(request); if (emitStableUrlAttributes) { - internalSet(attributes, UrlAttributes.URL_SCHEME, urlScheme); - internalSet(attributes, UrlAttributes.URL_PATH, urlPath); - internalSet(attributes, UrlAttributes.URL_QUERY, urlQuery); + internalSet(attributes, SemanticAttributes.URL_SCHEME, urlScheme); + internalSet(attributes, SemanticAttributes.URL_PATH, urlPath); + internalSet(attributes, SemanticAttributes.URL_QUERY, urlQuery); } if (emitOldHttpAttributes) { internalSet(attributes, SemanticAttributes.HTTP_SCHEME, urlScheme); diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/UrlAttributes.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/UrlAttributes.java deleted file mode 100644 index 01b8eb37c5..0000000000 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/url/internal/UrlAttributes.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.instrumenter.url.internal; - -import static io.opentelemetry.api.common.AttributeKey.stringKey; - -import io.opentelemetry.api.common.AttributeKey; - -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public final class UrlAttributes { - - // FIXME: remove this class and replace its usages with SemanticAttributes once schema 1.21 is - // released - - public static final AttributeKey URL_FULL = stringKey("url.full"); - - public static final AttributeKey URL_SCHEME = stringKey("url.scheme"); - - public static final AttributeKey URL_PATH = stringKey("url.path"); - - public static final AttributeKey URL_QUERY = stringKey("url.query"); - - private UrlAttributes() {} -} diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlAttributesExtractorTest.java index 3e0ab44464..bf6eebe6ec 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/url/UrlAttributesExtractorTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -56,9 +56,9 @@ class UrlAttributesExtractorTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(UrlAttributes.URL_SCHEME, "https"), - entry(UrlAttributes.URL_PATH, "/test"), - entry(UrlAttributes.URL_QUERY, "q=Java")); + entry(SemanticAttributes.URL_SCHEME, "https"), + entry(SemanticAttributes.URL_PATH, "/test"), + entry(SemanticAttributes.URL_QUERY, "q=Java")); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); diff --git a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorBothSemconvTest.java b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorBothSemconvTest.java index 85fa031ee0..7a98494dad 100644 --- a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorBothSemconvTest.java +++ b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorBothSemconvTest.java @@ -16,9 +16,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.List; @@ -138,37 +135,37 @@ class HttpClientAttributesExtractorBothSemconvTest { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.HTTP_METHOD, "POST"), - entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"), + entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"), entry(SemanticAttributes.HTTP_URL, "http://github.com"), - entry(UrlAttributes.URL_FULL, "http://github.com"), + entry(SemanticAttributes.URL_FULL, "http://github.com"), entry(SemanticAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"), entry( AttributeKey.stringArrayKey("http.request.header.custom_request_header"), asList("123", "456")), entry(SemanticAttributes.NET_PEER_NAME, "github.com"), entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(NetworkAttributes.SERVER_ADDRESS, "github.com"), - entry(NetworkAttributes.SERVER_PORT, 123L)); + entry(SemanticAttributes.SERVER_ADDRESS, "github.com"), + entry(SemanticAttributes.SERVER_PORT, 123L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, response, null); assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, 10L), - entry(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 10L), + entry(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 10L), entry(SemanticAttributes.HTTP_STATUS_CODE, 202L), - entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), + entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, 20L), - entry(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), + entry(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), entry(SemanticAttributes.HTTP_RESEND_COUNT, 2L), entry( AttributeKey.stringArrayKey("http.response.header.custom_response_header"), asList("654", "321")), entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"), entry(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1"), - entry(NetworkAttributes.NETWORK_TRANSPORT, "udp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv4"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); + entry(SemanticAttributes.NETWORK_TRANSPORT, "udp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv4"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); } } diff --git a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorBothSemconvTest.java b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorBothSemconvTest.java index 42991c27b9..d8d854207f 100644 --- a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorBothSemconvTest.java +++ b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorBothSemconvTest.java @@ -16,9 +16,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.List; @@ -159,18 +156,18 @@ class HttpServerAttributesExtractorBothSemconvTest { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_HOST_NAME, "github.com"), - entry(NetworkAttributes.SERVER_ADDRESS, "github.com"), + entry(SemanticAttributes.SERVER_ADDRESS, "github.com"), entry(SemanticAttributes.HTTP_METHOD, "POST"), - entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"), + entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"), entry(SemanticAttributes.HTTP_SCHEME, "http"), entry(SemanticAttributes.HTTP_TARGET, "/repositories/1?details=true"), - entry(UrlAttributes.URL_SCHEME, "http"), - entry(UrlAttributes.URL_PATH, "/repositories/1"), - entry(UrlAttributes.URL_QUERY, "details=true"), + entry(SemanticAttributes.URL_SCHEME, "http"), + entry(SemanticAttributes.URL_PATH, "/repositories/1"), + entry(SemanticAttributes.URL_QUERY, "details=true"), entry(SemanticAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"), entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{id}"), entry(SemanticAttributes.HTTP_CLIENT_IP, "1.1.1.1"), - entry(NetworkAttributes.CLIENT_ADDRESS, "1.1.1.1"), + entry(SemanticAttributes.CLIENT_ADDRESS, "1.1.1.1"), entry( AttributeKey.stringArrayKey("http.request.header.custom_request_header"), asList("123", "456"))); @@ -181,17 +178,17 @@ class HttpServerAttributesExtractorBothSemconvTest { .containsOnly( entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"), entry(SemanticAttributes.NET_PROTOCOL_VERSION, "2.0"), - entry(NetworkAttributes.NETWORK_TRANSPORT, "udp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv4"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + entry(SemanticAttributes.NETWORK_TRANSPORT, "udp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv4"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{repoId}"), entry(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, 10L), - entry(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 10L), + entry(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 10L), entry(SemanticAttributes.HTTP_STATUS_CODE, 202L), - entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), + entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), entry(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, 20L), - entry(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), + entry(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), entry( AttributeKey.stringArrayKey("http.response.header.custom_response_header"), asList("654", "321"))); diff --git a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorBothSemconvTest.java b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorBothSemconvTest.java index 33d97cf3f0..2bb799eaee 100644 --- a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorBothSemconvTest.java +++ b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorBothSemconvTest.java @@ -13,7 +13,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -126,24 +125,24 @@ class NetClientAttributesExtractorBothSemconvTest { .containsOnly( entry(SemanticAttributes.NET_PEER_NAME, "opentelemetry.io"), entry(SemanticAttributes.NET_PEER_PORT, 42L), - entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.SERVER_PORT, 42L)); + entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.SERVER_PORT, 42L)); assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, IP_TCP), entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"), entry(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1"), - entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv6"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), + entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv6"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), entry(SemanticAttributes.NET_SOCK_FAMILY, "inet6"), entry(SemanticAttributes.NET_SOCK_PEER_ADDR, "1:2:3:4::"), entry(SemanticAttributes.NET_SOCK_PEER_NAME, "proxy.opentelemetry.io"), entry(SemanticAttributes.NET_SOCK_PEER_PORT, 123L), - entry(NetworkAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1:2:3:4::"), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 123L)); + entry(SemanticAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1:2:3:4::"), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 123L)); } } diff --git a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorBothSemconvTest.java b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorBothSemconvTest.java index ee89adceb0..f1301379ee 100644 --- a/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorBothSemconvTest.java +++ b/instrumentation-api-semconv/src/testBothHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorBothSemconvTest.java @@ -13,7 +13,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; @@ -134,24 +133,24 @@ class NetServerAttributesExtractorBothSemconvTest { entry(SemanticAttributes.NET_TRANSPORT, IP_TCP), entry(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io"), entry(SemanticAttributes.NET_HOST_PORT, 80L), - entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.SERVER_PORT, 80L), + entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.SERVER_PORT, 80L), entry(SemanticAttributes.NET_SOCK_FAMILY, "inet6")); assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_SOCK_HOST_ADDR, "4:3:2:1::"), entry(SemanticAttributes.NET_SOCK_HOST_PORT, 8080L), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "4:3:2:1::"), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 8080L), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "4:3:2:1::"), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 8080L), entry(SemanticAttributes.NET_SOCK_PEER_ADDR, "1:2:3:4::"), entry(SemanticAttributes.NET_SOCK_PEER_PORT, 42L), - entry(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1:2:3:4::"), - entry(NetworkAttributes.CLIENT_SOCKET_PORT, 42L), - entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv6"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), + entry(SemanticAttributes.CLIENT_SOCKET_ADDRESS, "1:2:3:4::"), + entry(SemanticAttributes.CLIENT_SOCKET_PORT, 42L), + entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv6"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"), entry(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1")); } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java index 98e450dc0b..fa9e6e2eef 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractorStableSemconvTest.java @@ -18,9 +18,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.HttpConstants; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; @@ -148,30 +145,30 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"), - entry(UrlAttributes.URL_FULL, "http://github.com"), + entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"), + entry(SemanticAttributes.URL_FULL, "http://github.com"), entry(SemanticAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"), entry( AttributeKey.stringArrayKey("http.request.header.custom_request_header"), asList("123", "456")), - entry(NetworkAttributes.SERVER_ADDRESS, "github.com"), - entry(NetworkAttributes.SERVER_PORT, 123L)); + entry(SemanticAttributes.SERVER_ADDRESS, "github.com"), + entry(SemanticAttributes.SERVER_PORT, 123L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, response, null); assertThat(endAttributes.build()) .containsOnly( - entry(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 10L), - entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), - entry(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), + entry(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 10L), + entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), + entry(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), entry(SemanticAttributes.HTTP_RESEND_COUNT, 2L), entry( AttributeKey.stringArrayKey("http.response.header.custom_response_header"), asList("654", "321")), - entry(NetworkAttributes.NETWORK_TRANSPORT, "udp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv4"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); + entry(SemanticAttributes.NETWORK_TRANSPORT, "udp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv4"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); } @ParameterizedTest @@ -195,9 +192,9 @@ class HttpClientAttributesExtractorStableSemconvTest { if (extractedTransport != null) { assertThat(attributes.build()) - .containsEntry(NetworkAttributes.NETWORK_TRANSPORT, extractedTransport); + .containsEntry(SemanticAttributes.NETWORK_TRANSPORT, extractedTransport); } else { - assertThat(attributes.build()).doesNotContainKey(NetworkAttributes.NETWORK_TRANSPORT); + assertThat(attributes.build()).doesNotContainKey(SemanticAttributes.NETWORK_TRANSPORT); } } @@ -231,8 +228,8 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod) - .doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod) + .doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL); } @ParameterizedTest @@ -249,8 +246,8 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } @ParameterizedTest @@ -267,8 +264,8 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } @ParameterizedTest @@ -287,8 +284,8 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod) - .doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod) + .doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL); } @ParameterizedTest @@ -307,7 +304,7 @@ class HttpClientAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientExperimentalMetricsStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientExperimentalMetricsStableSemconvTest.java index 6b22eabc2b..c3def5c219 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientExperimentalMetricsStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientExperimentalMetricsStableSemconvTest.java @@ -15,11 +15,9 @@ import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.OperationListener; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -36,25 +34,25 @@ class HttpClientExperimentalMetricsStableSemconvTest { Attributes requestAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET") - .put(UrlAttributes.URL_FULL, "https://localhost:1234/") - .put(UrlAttributes.URL_SCHEME, "https") - .put(UrlAttributes.URL_PATH, "/") - .put(UrlAttributes.URL_QUERY, "q=a") - .put(NetworkAttributes.SERVER_ADDRESS, "localhost") - .put(NetworkAttributes.SERVER_PORT, 1234) + .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") + .put(SemanticAttributes.URL_FULL, "https://localhost:1234/") + .put(SemanticAttributes.URL_SCHEME, "https") + .put(SemanticAttributes.URL_PATH, "/") + .put(SemanticAttributes.URL_QUERY, "q=a") + .put(SemanticAttributes.SERVER_ADDRESS, "localhost") + .put(SemanticAttributes.SERVER_PORT, 1234) .build(); Attributes responseAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200) - .put(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 100) - .put(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 200) - .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http") - .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0") - .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4") - .put(NetworkAttributes.SERVER_SOCKET_DOMAIN, "somehost20") - .put(NetworkAttributes.SERVER_SOCKET_PORT, 8080) + .put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200) + .put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100) + .put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200) + .put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http") + .put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0") + .put(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4") + .put(SemanticAttributes.SERVER_SOCKET_DOMAIN, "somehost20") + .put(SemanticAttributes.SERVER_SOCKET_PORT, 8080) .build(); Context parent = @@ -90,16 +88,18 @@ class HttpClientExperimentalMetricsStableSemconvTest { point .hasSum(100 /* bytes */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(NetworkAttributes.SERVER_ADDRESS, "localhost"), - equalTo(NetworkAttributes.SERVER_PORT, 1234), + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), equalTo( - NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")) + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), + equalTo(SemanticAttributes.SERVER_PORT, 1234), + equalTo( + SemanticAttributes.SERVER_SOCKET_ADDRESS, + "1.2.3.4")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -116,16 +116,18 @@ class HttpClientExperimentalMetricsStableSemconvTest { point .hasSum(200 /* bytes */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(NetworkAttributes.SERVER_ADDRESS, "localhost"), - equalTo(NetworkAttributes.SERVER_PORT, 1234), + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), equalTo( - NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")) + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), + equalTo(SemanticAttributes.SERVER_PORT, 1234), + equalTo( + SemanticAttributes.SERVER_SOCKET_ADDRESS, + "1.2.3.4")) .hasExemplarsSatisfying( exemplar -> exemplar diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsStableSemconvTest.java index a843fd3017..abe819dd15 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsStableSemconvTest.java @@ -15,11 +15,9 @@ import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.OperationListener; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -38,25 +36,25 @@ class HttpClientMetricsStableSemconvTest { Attributes requestAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET") - .put(UrlAttributes.URL_FULL, "https://localhost:1234/") - .put(UrlAttributes.URL_SCHEME, "https") - .put(UrlAttributes.URL_PATH, "/") - .put(UrlAttributes.URL_QUERY, "q=a") - .put(NetworkAttributes.SERVER_ADDRESS, "localhost") - .put(NetworkAttributes.SERVER_PORT, 1234) + .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") + .put(SemanticAttributes.URL_FULL, "https://localhost:1234/") + .put(SemanticAttributes.URL_SCHEME, "https") + .put(SemanticAttributes.URL_PATH, "/") + .put(SemanticAttributes.URL_QUERY, "q=a") + .put(SemanticAttributes.SERVER_ADDRESS, "localhost") + .put(SemanticAttributes.SERVER_PORT, 1234) .build(); Attributes responseAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200) - .put(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 100) - .put(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 200) - .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http") - .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0") - .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4") - .put(NetworkAttributes.SERVER_SOCKET_DOMAIN, "somehost20") - .put(NetworkAttributes.SERVER_SOCKET_PORT, 8080) + .put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200) + .put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100) + .put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200) + .put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http") + .put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0") + .put(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4") + .put(SemanticAttributes.SERVER_SOCKET_DOMAIN, "somehost20") + .put(SemanticAttributes.SERVER_SOCKET_PORT, 8080) .build(); Context parent = @@ -92,16 +90,18 @@ class HttpClientMetricsStableSemconvTest { point .hasSum(0.15 /* seconds */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(NetworkAttributes.SERVER_ADDRESS, "localhost"), - equalTo(NetworkAttributes.SERVER_PORT, 1234), + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), equalTo( - NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")) + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"), + equalTo(SemanticAttributes.SERVER_PORT, 1234), + equalTo( + SemanticAttributes.SERVER_SOCKET_ADDRESS, + "1.2.3.4")) .hasExemplarsSatisfying( exemplar -> exemplar diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorStableSemconvTest.java index 10bd0bd800..6722784a69 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractorStableSemconvTest.java @@ -18,9 +18,6 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.HttpConstants; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; @@ -186,14 +183,14 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_ADDRESS, "github.com"), - entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"), - entry(UrlAttributes.URL_SCHEME, "http"), - entry(UrlAttributes.URL_PATH, "/repositories/1"), - entry(UrlAttributes.URL_QUERY, "details=true"), + entry(SemanticAttributes.SERVER_ADDRESS, "github.com"), + entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"), + entry(SemanticAttributes.URL_SCHEME, "http"), + entry(SemanticAttributes.URL_PATH, "/repositories/1"), + entry(SemanticAttributes.URL_QUERY, "details=true"), entry(SemanticAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"), entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{id}"), - entry(NetworkAttributes.CLIENT_ADDRESS, "1.1.1.1"), + entry(SemanticAttributes.CLIENT_ADDRESS, "1.1.1.1"), entry( AttributeKey.stringArrayKey("http.request.header.custom_request_header"), asList("123", "456"))); @@ -202,14 +199,14 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(endAttributes, Context.root(), request, response, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.NETWORK_TRANSPORT, "udp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv4"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + entry(SemanticAttributes.NETWORK_TRANSPORT, "udp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv4"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{repoId}"), - entry(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 10L), - entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), - entry(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), + entry(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 10L), + entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L), + entry(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 20L), entry( AttributeKey.stringArrayKey("http.response.header.custom_response_header"), asList("654", "321"))); @@ -236,9 +233,9 @@ class HttpServerAttributesExtractorStableSemconvTest { if (extractedTransport != null) { assertThat(attributes.build()) - .containsEntry(NetworkAttributes.NETWORK_TRANSPORT, extractedTransport); + .containsEntry(SemanticAttributes.NETWORK_TRANSPORT, extractedTransport); } else { - assertThat(attributes.build()).doesNotContainKey(NetworkAttributes.NETWORK_TRANSPORT); + assertThat(attributes.build()).doesNotContainKey(SemanticAttributes.NETWORK_TRANSPORT); } } @@ -272,8 +269,8 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod) - .doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod) + .doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL); } @ParameterizedTest @@ -290,8 +287,8 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } @ParameterizedTest @@ -308,8 +305,8 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } @ParameterizedTest @@ -328,8 +325,8 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod) - .doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod) + .doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL); } @ParameterizedTest @@ -348,7 +345,7 @@ class HttpServerAttributesExtractorStableSemconvTest { extractor.onEnd(attributes, Context.root(), request, emptyMap(), null); assertThat(attributes.build()) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) - .containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER) + .containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod); } } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerExperimentalMetricsStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerExperimentalMetricsStableSemconvTest.java index a3562317ba..16c719c38e 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerExperimentalMetricsStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerExperimentalMetricsStableSemconvTest.java @@ -15,11 +15,9 @@ import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.OperationListener; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -36,27 +34,27 @@ class HttpServerExperimentalMetricsStableSemconvTest { Attributes requestAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET") - .put(UrlAttributes.URL_SCHEME, "https") - .put(UrlAttributes.URL_PATH, "/") - .put(UrlAttributes.URL_QUERY, "q=a") - .put(NetworkAttributes.NETWORK_TRANSPORT, "tcp") - .put(NetworkAttributes.NETWORK_TYPE, "ipv4") - .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http") - .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0") - .put(NetworkAttributes.SERVER_ADDRESS, "localhost") - .put(NetworkAttributes.SERVER_PORT, 1234) + .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") + .put(SemanticAttributes.URL_SCHEME, "https") + .put(SemanticAttributes.URL_PATH, "/") + .put(SemanticAttributes.URL_QUERY, "q=a") + .put(SemanticAttributes.NETWORK_TRANSPORT, "tcp") + .put(SemanticAttributes.NETWORK_TYPE, "ipv4") + .put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http") + .put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0") + .put(SemanticAttributes.SERVER_ADDRESS, "localhost") + .put(SemanticAttributes.SERVER_PORT, 1234) .build(); Attributes responseAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200) - .put(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 100) - .put(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 200) - .put(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4") - .put(NetworkAttributes.CLIENT_SOCKET_PORT, 8080) - .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "4.3.2.1") - .put(NetworkAttributes.SERVER_SOCKET_PORT, 9090) + .put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200) + .put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100) + .put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200) + .put(SemanticAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4") + .put(SemanticAttributes.CLIENT_SOCKET_PORT, 8080) + .put(SemanticAttributes.SERVER_SOCKET_ADDRESS, "4.3.2.1") + .put(SemanticAttributes.SERVER_SOCKET_PORT, 9090) .build(); SpanContext spanContext1 = @@ -90,8 +88,8 @@ class HttpServerExperimentalMetricsStableSemconvTest { point .hasValue(1) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -113,8 +111,8 @@ class HttpServerExperimentalMetricsStableSemconvTest { point .hasValue(2) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -135,8 +133,8 @@ class HttpServerExperimentalMetricsStableSemconvTest { point .hasValue(1) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -153,13 +151,14 @@ class HttpServerExperimentalMetricsStableSemconvTest { point .hasSum(100 /* bytes */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + equalTo( + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -176,13 +175,14 @@ class HttpServerExperimentalMetricsStableSemconvTest { point .hasSum(200 /* bytes */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + equalTo( + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerMetricsStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerMetricsStableSemconvTest.java index 6f8a132ed4..e2ed2cb950 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerMetricsStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerMetricsStableSemconvTest.java @@ -15,9 +15,6 @@ import io.opentelemetry.api.trace.TraceFlags; import io.opentelemetry.api.trace.TraceState; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.OperationListener; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; import io.opentelemetry.semconv.SemanticAttributes; @@ -39,27 +36,27 @@ class HttpServerMetricsStableSemconvTest { Attributes requestAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET") - .put(UrlAttributes.URL_SCHEME, "https") - .put(UrlAttributes.URL_PATH, "/") - .put(UrlAttributes.URL_QUERY, "q=a") - .put(NetworkAttributes.NETWORK_TRANSPORT, "tcp") - .put(NetworkAttributes.NETWORK_TYPE, "ipv4") - .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http") - .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0") - .put(NetworkAttributes.SERVER_ADDRESS, "localhost") - .put(NetworkAttributes.SERVER_PORT, 1234) + .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") + .put(SemanticAttributes.URL_SCHEME, "https") + .put(SemanticAttributes.URL_PATH, "/") + .put(SemanticAttributes.URL_QUERY, "q=a") + .put(SemanticAttributes.NETWORK_TRANSPORT, "tcp") + .put(SemanticAttributes.NETWORK_TYPE, "ipv4") + .put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http") + .put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0") + .put(SemanticAttributes.SERVER_ADDRESS, "localhost") + .put(SemanticAttributes.SERVER_PORT, 1234) .build(); Attributes responseAttributes = Attributes.builder() - .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200) - .put(HttpAttributes.HTTP_REQUEST_BODY_SIZE, 100) - .put(HttpAttributes.HTTP_RESPONSE_BODY_SIZE, 200) - .put(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4") - .put(NetworkAttributes.CLIENT_SOCKET_PORT, 8080) - .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "4.3.2.1") - .put(NetworkAttributes.SERVER_SOCKET_PORT, 9090) + .put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200) + .put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100) + .put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200) + .put(SemanticAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4") + .put(SemanticAttributes.CLIENT_SOCKET_PORT, 8080) + .put(SemanticAttributes.SERVER_SOCKET_ADDRESS, "4.3.2.1") + .put(SemanticAttributes.SERVER_SOCKET_PORT, 9090) .build(); SpanContext spanContext1 = @@ -96,13 +93,14 @@ class HttpServerMetricsStableSemconvTest { point .hasSum(0.15 /* seconds */) .hasAttributesSatisfying( - equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"), - equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), equalTo( - NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), - equalTo(UrlAttributes.URL_SCHEME, "https")) + SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + equalTo( + SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"), + equalTo(SemanticAttributes.URL_SCHEME, "https")) .hasExemplarsSatisfying( exemplar -> exemplar @@ -141,8 +139,8 @@ class HttpServerMetricsStableSemconvTest { Attributes requestAttributes = Attributes.builder() - .put(NetworkAttributes.SERVER_ADDRESS, "host") - .put(UrlAttributes.URL_SCHEME, "https") + .put(SemanticAttributes.SERVER_ADDRESS, "host") + .put(SemanticAttributes.URL_SCHEME, "https") .build(); Attributes responseAttributes = @@ -168,7 +166,7 @@ class HttpServerMetricsStableSemconvTest { point .hasSum(0.100 /* seconds */) .hasAttributesSatisfying( - equalTo(UrlAttributes.URL_SCHEME, "https"), + equalTo(SemanticAttributes.URL_SCHEME, "https"), equalTo( SemanticAttributes.HTTP_ROUTE, "/test/{id}"))))); } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorStableSemconvTest.java index e7c5b158f5..b27fdbe9bb 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorStableSemconvTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -123,17 +123,17 @@ class NetClientAttributesExtractorStableSemconvTest { // then assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.SERVER_PORT, 42L)); + entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.SERVER_PORT, 42L)); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv6"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), - entry(NetworkAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1:2:3:4::"), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 123L)); + entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv6"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), + entry(SemanticAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1:2:3:4::"), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 123L)); } } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorStableSemconvTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorStableSemconvTest.java index 8cadd0bdfc..c44698dae7 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorStableSemconvTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorStableSemconvTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -130,18 +130,18 @@ class NetServerAttributesExtractorStableSemconvTest { // then assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.SERVER_PORT, 80L)); + entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.SERVER_PORT, 80L)); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv6"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "4:3:2:1::"), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 8080L), - entry(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1:2:3:4::"), - entry(NetworkAttributes.CLIENT_SOCKET_PORT, 42L)); + entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv6"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "4:3:2:1::"), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 8080L), + entry(SemanticAttributes.CLIENT_SOCKET_ADDRESS, "1:2:3:4::"), + entry(SemanticAttributes.CLIENT_SOCKET_PORT, 42L)); } } diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorInetSocketAddressTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorInetSocketAddressTest.java index 0fffabab01..70ecb02d7c 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorInetSocketAddressTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorInetSocketAddressTest.java @@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.junit.jupiter.api.Test; @@ -61,8 +61,8 @@ class ClientAttributesExtractorInetSocketAddressTest { extractor.onEnd(endAttributes, Context.root(), address, null, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.CLIENT_SOCKET_ADDRESS, address.getAddress().getHostAddress()), - entry(NetworkAttributes.CLIENT_SOCKET_PORT, 456L)); + entry(SemanticAttributes.CLIENT_SOCKET_ADDRESS, address.getAddress().getHostAddress()), + entry(SemanticAttributes.CLIENT_SOCKET_PORT, 456L)); } @Test diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorTest.java index d42f97a31e..170d70fcc6 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ClientAttributesExtractorTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -66,15 +66,15 @@ class ClientAttributesExtractorTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.CLIENT_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.CLIENT_PORT, 80L)); + entry(SemanticAttributes.CLIENT_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.CLIENT_PORT, 80L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4"), - entry(NetworkAttributes.CLIENT_SOCKET_PORT, 8080L)); + entry(SemanticAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4"), + entry(SemanticAttributes.CLIENT_SOCKET_PORT, 8080L)); } @Test @@ -124,8 +124,8 @@ class ClientAttributesExtractorTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.CLIENT_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.CLIENT_PORT, 80L)); + entry(SemanticAttributes.CLIENT_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.CLIENT_PORT, 80L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractorTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractorTest.java index 9370314066..4bc8edbf2c 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractorTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -68,10 +68,10 @@ class NetworkAttributesExtractorTest { extractor.onEnd(endAttributes, Context.root(), request, null, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"), - entry(NetworkAttributes.NETWORK_TYPE, "ipv4"), - entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"), - entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); + entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"), + entry(SemanticAttributes.NETWORK_TYPE, "ipv4"), + entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"), + entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")); } @Test diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorInetSocketAddressTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorInetSocketAddressTest.java index 42fe2a2336..4926fd4a23 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorInetSocketAddressTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorInetSocketAddressTest.java @@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.junit.jupiter.api.Test; @@ -61,9 +61,9 @@ class ServerAttributesExtractorInetSocketAddressTest { extractor.onEnd(endAttributes, Context.root(), address, null, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_SOCKET_DOMAIN, "api.github.com"), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, address.getAddress().getHostAddress()), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 456L)); + entry(SemanticAttributes.SERVER_SOCKET_DOMAIN, "api.github.com"), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, address.getAddress().getHostAddress()), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 456L)); } @Test diff --git a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorTest.java b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorTest.java index 8f2806514c..96d43e3b91 100644 --- a/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/testStableHttpSemconv/java/io/opentelemetry/instrumentation/api/instrumenter/network/ServerAttributesExtractorTest.java @@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; import java.util.Map; import javax.annotation.Nullable; @@ -73,16 +73,16 @@ class ServerAttributesExtractorTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io"), - entry(NetworkAttributes.SERVER_PORT, 80L)); + entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"), + entry(SemanticAttributes.SERVER_PORT, 80L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); assertThat(endAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), - entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4"), - entry(NetworkAttributes.SERVER_SOCKET_PORT, 8080L)); + entry(SemanticAttributes.SERVER_SOCKET_DOMAIN, "proxy.opentelemetry.io"), + entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4"), + entry(SemanticAttributes.SERVER_SOCKET_PORT, 8080L)); } @Test @@ -113,12 +113,12 @@ class ServerAttributesExtractorTest { AttributesBuilder startAttributes = Attributes.builder(); extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) - .containsOnly(entry(NetworkAttributes.SERVER_ADDRESS, "opentelemetry.io")); + .containsOnly(entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io")); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); assertThat(endAttributes.build()) - .containsOnly(entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")); + .containsOnly(entry(SemanticAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")); } @Test @@ -137,8 +137,8 @@ class ServerAttributesExtractorTest { extractor.onStart(startAttributes, Context.root(), request); assertThat(startAttributes.build()) .containsOnly( - entry(NetworkAttributes.SERVER_ADDRESS, "1.2.3.4"), - entry(NetworkAttributes.SERVER_PORT, 80L)); + entry(SemanticAttributes.SERVER_ADDRESS, "1.2.3.4"), + entry(SemanticAttributes.SERVER_PORT, 80L)); AttributesBuilder endAttributes = Attributes.builder(); extractor.onEnd(endAttributes, Context.root(), request, null, null); diff --git a/instrumentation/aws-lambda/aws-lambda-events-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/v2_2/internal/ApiGatewayProxyAttributesExtractor.java b/instrumentation/aws-lambda/aws-lambda-events-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/v2_2/internal/ApiGatewayProxyAttributesExtractor.java index d0c3e5424f..bdb42099cb 100644 --- a/instrumentation/aws-lambda/aws-lambda-events-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/v2_2/internal/ApiGatewayProxyAttributesExtractor.java +++ b/instrumentation/aws-lambda/aws-lambda-events-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/v2_2/internal/ApiGatewayProxyAttributesExtractor.java @@ -5,12 +5,12 @@ package io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal; -import static io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes.HTTP_RESPONSE_STATUS_CODE; import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; import static io.opentelemetry.instrumentation.api.internal.HttpConstants._OTHER; import static io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.MapUtils.emptyIfNull; import static io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.MapUtils.lowercaseMap; import static io.opentelemetry.semconv.SemanticAttributes.FAAS_TRIGGER; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.USER_AGENT_ORIGINAL; @@ -19,8 +19,6 @@ import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest; import io.opentelemetry.semconv.SemanticAttributes; @@ -54,10 +52,10 @@ final class ApiGatewayProxyAttributesExtractor String method = request.getHttpMethod(); if (SemconvStability.emitStableHttpSemconv()) { if (method == null || knownMethods.contains(method)) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method); } else { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); } } if (SemconvStability.emitOldHttpSemconv()) { @@ -73,7 +71,7 @@ final class ApiGatewayProxyAttributesExtractor String httpUrl = getHttpUrl(request, headers); if (httpUrl != null) { if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, UrlAttributes.URL_FULL, httpUrl); + internalSet(attributes, SemanticAttributes.URL_FULL, httpUrl); } if (SemconvStability.emitOldHttpSemconv()) { diff --git a/instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java b/instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java index 56a27e5342..30a3548440 100644 --- a/instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java +++ b/instrumentation/camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java @@ -30,8 +30,6 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRoute; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRouteSource; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection; @@ -102,7 +100,7 @@ class HttpSpanDecorator extends BaseSpanDecorator { String httpUrl = getHttpUrl(exchange, endpoint); if (httpUrl != null) { if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, UrlAttributes.URL_FULL, httpUrl); + internalSet(attributes, SemanticAttributes.URL_FULL, httpUrl); } if (SemconvStability.emitOldHttpSemconv()) { @@ -113,10 +111,10 @@ class HttpSpanDecorator extends BaseSpanDecorator { String method = getHttpMethod(exchange, endpoint); if (SemconvStability.emitStableHttpSemconv()) { if (method == null || knownMethods.contains(method)) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method); } else { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); } } if (SemconvStability.emitOldHttpSemconv()) { @@ -185,7 +183,7 @@ class HttpSpanDecorator extends BaseSpanDecorator { Object responseCode = exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE); if (responseCode instanceof Integer) { if (SemconvStability.emitStableHttpSemconv()) { - attributes.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, (Integer) responseCode); + attributes.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, (Integer) responseCode); } if (SemconvStability.emitOldHttpSemconv()) { attributes.put(SemanticAttributes.HTTP_STATUS_CODE, (Integer) responseCode); diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchClientAttributeExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchClientAttributeExtractor.java index b747f85c15..0d81b3c705 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchClientAttributeExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchClientAttributeExtractor.java @@ -12,9 +12,6 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.internal.cache.Cache; import io.opentelemetry.semconv.SemanticAttributes; @@ -46,8 +43,8 @@ public class ElasticsearchClientAttributeExtractor HttpHost host = response.getHost(); if (host != null) { if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, NetworkAttributes.SERVER_ADDRESS, host.getHostName()); - internalSet(attributes, NetworkAttributes.SERVER_PORT, (long) host.getPort()); + internalSet(attributes, SemanticAttributes.SERVER_ADDRESS, host.getHostName()); + internalSet(attributes, SemanticAttributes.SERVER_PORT, (long) host.getPort()); } if (SemconvStability.emitOldHttpSemconv()) { internalSet(attributes, SemanticAttributes.NET_PEER_NAME, host.getHostName()); @@ -63,7 +60,7 @@ public class ElasticsearchClientAttributeExtractor String fullUrl = response.getHost().toURI() + uri; if (SemconvStability.emitStableHttpSemconv()) { - internalSet(attributes, UrlAttributes.URL_FULL, fullUrl); + internalSet(attributes, SemanticAttributes.URL_FULL, fullUrl); } if (SemconvStability.emitOldHttpSemconv()) { @@ -95,10 +92,10 @@ public class ElasticsearchClientAttributeExtractor String method = request.getMethod(); if (SemconvStability.emitStableHttpSemconv()) { if (method == null || knownMethods.contains(method)) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method); } else { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); } } if (SemconvStability.emitOldHttpSemconv()) { diff --git a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpMethodAttributeExtractor.java b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpMethodAttributeExtractor.java index 05ff160272..fc988d4eee 100644 --- a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpMethodAttributeExtractor.java +++ b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpMethodAttributeExtractor.java @@ -12,7 +12,6 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.api.trace.Span; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.SemanticAttributes; import java.net.HttpURLConnection; @@ -54,11 +53,11 @@ public class HttpMethodAttributeExtractor< // The getOutputStream() has transformed "GET" into "POST" if (SemconvStability.emitStableHttpSemconv()) { if (knownMethods.contains(method)) { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method); - attributes.remove(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method); + attributes.remove(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL); } else { - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER); - internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER); + internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method); } } if (SemconvStability.emitOldHttpSemconv()) { diff --git a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy index 1a52fc9ad0..de637ac052 100644 --- a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy +++ b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy @@ -18,7 +18,7 @@ import io.netty.handler.codec.http.HttpHeaders import io.netty.handler.codec.http.HttpMethod import io.netty.handler.codec.http.HttpVersion import io.netty.handler.ssl.SslHandler -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes + import io.opentelemetry.instrumentation.api.internal.SemconvStability import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestServer @@ -100,11 +100,11 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -125,11 +125,11 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_SOCKET_DOMAIN" uri.host - "$NetworkAttributes.SERVER_SOCKET_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_SOCKET_DOMAIN" uri.host + "$SemanticAttributes.SERVER_SOCKET_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -178,11 +178,11 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -200,11 +200,11 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_SOCKET_DOMAIN" uri.host - "$NetworkAttributes.SERVER_SOCKET_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_SOCKET_DOMAIN" uri.host + "$SemanticAttributes.SERVER_SOCKET_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } diff --git a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy index 321aa799a8..b2bba7eb52 100644 --- a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy +++ b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy @@ -16,7 +16,7 @@ import io.netty.handler.codec.http.HttpClientCodec import io.netty.handler.codec.http.HttpHeaders import io.netty.handler.codec.http.HttpMethod import io.netty.handler.codec.http.HttpVersion -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes + import io.opentelemetry.instrumentation.api.internal.SemconvStability import io.opentelemetry.instrumentation.test.AgentTestTrait import io.opentelemetry.instrumentation.test.InstrumentationSpecification @@ -116,11 +116,11 @@ class Netty40ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -175,11 +175,11 @@ class Netty40ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == null } - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" { it == "127.0.0.1" || it == null } + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == null } + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" { it == "127.0.0.1" || it == null } } } } diff --git a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy index 4828bde3e9..84860ba077 100644 --- a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy +++ b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy @@ -20,7 +20,7 @@ import io.netty.handler.codec.http.HttpVersion import io.netty.handler.ssl.SslContext import io.netty.handler.ssl.SslContextBuilder import io.netty.handler.ssl.SslHandler -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes + import io.opentelemetry.instrumentation.api.internal.SemconvStability import io.opentelemetry.instrumentation.netty.v4_1.ClientHandler import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification @@ -104,8 +104,8 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port } } } @@ -123,11 +123,11 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -148,11 +148,11 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_SOCKET_DOMAIN" uri.host - "$NetworkAttributes.SERVER_SOCKET_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_SOCKET_DOMAIN" uri.host + "$SemanticAttributes.SERVER_SOCKET_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -202,8 +202,8 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port } } } @@ -221,11 +221,11 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -243,11 +243,11 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_SOCKET_DOMAIN" uri.host - "$NetworkAttributes.SERVER_SOCKET_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_SOCKET_DOMAIN" uri.host + "$SemanticAttributes.SERVER_SOCKET_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } diff --git a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy index 425d562694..016ef99620 100644 --- a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy +++ b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy @@ -16,7 +16,7 @@ import io.netty.handler.codec.http.HttpClientCodec import io.netty.handler.codec.http.HttpHeaderNames import io.netty.handler.codec.http.HttpMethod import io.netty.handler.codec.http.HttpVersion -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes + import io.opentelemetry.instrumentation.api.internal.SemconvStability import io.opentelemetry.instrumentation.netty.v4_1.ClientHandler import io.opentelemetry.instrumentation.test.AgentTestTrait @@ -118,8 +118,8 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port } } } @@ -137,11 +137,11 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" "127.0.0.1" } } } @@ -195,8 +195,8 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port } } } @@ -216,11 +216,11 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.NETWORK_TRANSPORT" "tcp" - "$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == null } - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.SERVER_SOCKET_ADDRESS" { it == "127.0.0.1" || it == null } + "$SemanticAttributes.NETWORK_TRANSPORT" "tcp" + "$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == null } + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.SERVER_SOCKET_ADDRESS" { it == "127.0.0.1" || it == null } } } } diff --git a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy index a3f544770a..e6050d7c9c 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy @@ -7,9 +7,7 @@ import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.api.trace.StatusCode -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes + import io.opentelemetry.instrumentation.api.internal.SemconvStability import io.opentelemetry.instrumentation.test.AgentTestTrait import io.opentelemetry.instrumentation.test.base.HttpServerTest @@ -166,20 +164,20 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.CLIENT_ADDRESS" TEST_CLIENT_IP - "$UrlAttributes.URL_SCHEME" uri.getScheme() - "$UrlAttributes.URL_PATH" uri.getPath() - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200 + "$SemanticAttributes.CLIENT_ADDRESS" TEST_CLIENT_IP + "$SemanticAttributes.URL_SCHEME" uri.getScheme() + "$SemanticAttributes.URL_PATH" uri.getPath() + "$SemanticAttributes.HTTP_REQUEST_METHOD" "GET" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.USER_AGENT_ORIGINAL" TEST_USER_AGENT - "$HttpAttributes.HTTP_RESPONSE_BODY_SIZE" Long - "$NetworkAttributes.NETWORK_PROTOCOL_NAME" "http" - "$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.CLIENT_SOCKET_ADDRESS" "127.0.0.1" - "$NetworkAttributes.CLIENT_SOCKET_PORT" Long + "$SemanticAttributes.HTTP_RESPONSE_BODY_SIZE" Long + "$SemanticAttributes.NETWORK_PROTOCOL_NAME" "http" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.CLIENT_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.CLIENT_SOCKET_PORT" Long } } } @@ -238,20 +236,20 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr } if (SemconvStability.emitStableHttpSemconv()) { attributes { - "$NetworkAttributes.CLIENT_ADDRESS" TEST_CLIENT_IP - "$UrlAttributes.URL_SCHEME" uri.getScheme() - "$UrlAttributes.URL_PATH" uri.getPath() - "$HttpAttributes.HTTP_REQUEST_METHOD" "GET" - "$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200 + "$SemanticAttributes.CLIENT_ADDRESS" TEST_CLIENT_IP + "$SemanticAttributes.URL_SCHEME" uri.getScheme() + "$SemanticAttributes.URL_PATH" uri.getPath() + "$SemanticAttributes.HTTP_REQUEST_METHOD" "GET" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.USER_AGENT_ORIGINAL" TEST_USER_AGENT - "$HttpAttributes.HTTP_RESPONSE_BODY_SIZE" Long - "$NetworkAttributes.NETWORK_PROTOCOL_NAME" "http" - "$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1" - "$NetworkAttributes.NETWORK_TYPE" "ipv4" - "$NetworkAttributes.SERVER_ADDRESS" uri.host - "$NetworkAttributes.SERVER_PORT" uri.port - "$NetworkAttributes.CLIENT_SOCKET_ADDRESS" "127.0.0.1" - "$NetworkAttributes.CLIENT_SOCKET_PORT" Long + "$SemanticAttributes.HTTP_RESPONSE_BODY_SIZE" Long + "$SemanticAttributes.NETWORK_PROTOCOL_NAME" "http" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" + "$SemanticAttributes.NETWORK_TYPE" "ipv4" + "$SemanticAttributes.SERVER_ADDRESS" uri.host + "$SemanticAttributes.SERVER_PORT" uri.port + "$SemanticAttributes.CLIENT_SOCKET_ADDRESS" "127.0.0.1" + "$SemanticAttributes.CLIENT_SOCKET_PORT" Long } } } diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java index 062aa5a076..50d4ef081e 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java @@ -17,8 +17,6 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; import io.opentelemetry.instrumentation.api.internal.HttpConstants; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.test.utils.PortUtils; @@ -137,7 +135,7 @@ public abstract class AbstractHttpClientTest implements HttpClientTypeA span -> assertClientSpan(span, uri, HttpConstants._OTHER, responseCode, null) .hasNoParent() - .hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method))); + .hasAttribute(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method))); } @ParameterizedTest @@ -999,12 +997,12 @@ public abstract class AbstractHttpClientTest implements HttpClientTypeA assertThat(attrs).containsEntry(SemanticAttributes.NET_TRANSPORT, IP_TCP); } if (SemconvStability.emitStableHttpSemconv() - && attrs.get(NetworkAttributes.NETWORK_TRANSPORT) != null) { - assertThat(attrs).containsEntry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"); + && attrs.get(SemanticAttributes.NETWORK_TRANSPORT) != null) { + assertThat(attrs).containsEntry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"); } if (SemconvStability.emitStableHttpSemconv() - && attrs.get(NetworkAttributes.NETWORK_TYPE) != null) { - assertThat(attrs).containsEntry(NetworkAttributes.NETWORK_TYPE, "ipv4"); + && attrs.get(SemanticAttributes.NETWORK_TYPE) != null) { + assertThat(attrs).containsEntry(SemanticAttributes.NETWORK_TYPE, "ipv4"); } AttributeKey netProtocolKey = getAttributeKey(SemanticAttributes.NET_PROTOCOL_NAME); diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java index c3dba18bff..ac2544fac4 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java @@ -27,9 +27,6 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.context.propagation.TextMapSetter; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.HttpConstants; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.GlobalTraceUtil; @@ -523,7 +520,7 @@ public abstract class AbstractHttpServerTest extends AbstractHttpServerU HttpConstants._OTHER, SUCCESS, options.responseCodeOnNonStandardHttpMethod) - .hasAttribute(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method))); + .hasAttribute(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method))); } finally { eventLoopGroup.shutdownGracefully().await(10, TimeUnit.SECONDS); } @@ -746,12 +743,12 @@ public abstract class AbstractHttpServerTest extends AbstractHttpServerU assertThat(attrs).containsEntry(SemanticAttributes.NET_TRANSPORT, IP_TCP); } if (SemconvStability.emitStableHttpSemconv() - && attrs.get(NetworkAttributes.NETWORK_TRANSPORT) != null) { - assertThat(attrs).containsEntry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"); + && attrs.get(SemanticAttributes.NETWORK_TRANSPORT) != null) { + assertThat(attrs).containsEntry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"); } if (SemconvStability.emitStableHttpSemconv() - && attrs.get(NetworkAttributes.NETWORK_TYPE) != null) { - assertThat(attrs).containsEntry(NetworkAttributes.NETWORK_TYPE, "ipv4"); + && attrs.get(SemanticAttributes.NETWORK_TYPE) != null) { + assertThat(attrs).containsEntry(SemanticAttributes.NETWORK_TYPE, "ipv4"); } assertThat(attrs) @@ -794,10 +791,10 @@ public abstract class AbstractHttpServerTest extends AbstractHttpServerU value -> assertThat(value).isNull(), value -> assertThat(value).isEqualTo(TEST_CLIENT_IP))); if (SemconvStability.emitStableHttpSemconv() - && attrs.get(NetworkAttributes.CLIENT_PORT) != null) { + && attrs.get(SemanticAttributes.CLIENT_PORT) != null) { assertThat(attrs) .hasEntrySatisfying( - NetworkAttributes.CLIENT_PORT, port -> assertThat(port).isGreaterThan(0)); + SemanticAttributes.CLIENT_PORT, port -> assertThat(port).isGreaterThan(0)); } assertThat(attrs).containsEntry(getAttributeKey(SemanticAttributes.HTTP_METHOD), method); assertThat(attrs) @@ -828,9 +825,10 @@ public abstract class AbstractHttpServerTest extends AbstractHttpServerU } if (SemconvStability.emitStableHttpSemconv()) { assertThat(attrs) - .containsEntry(UrlAttributes.URL_PATH, endpoint.resolvePath(address).getPath()); + .containsEntry( + SemanticAttributes.URL_PATH, endpoint.resolvePath(address).getPath()); if (endpoint.getQuery() != null) { - assertThat(attrs).containsEntry(UrlAttributes.URL_QUERY, endpoint.getQuery()); + assertThat(attrs).containsEntry(SemanticAttributes.URL_QUERY, endpoint.getQuery()); } } } @@ -888,8 +886,8 @@ public abstract class AbstractHttpServerTest extends AbstractHttpServerU } if (SemconvStability.emitStableHttpSemconv()) { span.hasAttributesSatisfying( - equalTo(UrlAttributes.URL_PATH, endpoint.resolvePath(address).getPath())); - span.hasAttributesSatisfying(equalTo(UrlAttributes.URL_QUERY, "id=" + requestId)); + equalTo(SemanticAttributes.URL_PATH, endpoint.resolvePath(address).getPath())); + span.hasAttributesSatisfying(equalTo(SemanticAttributes.URL_QUERY, "id=" + requestId)); } return span; diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/SemconvStabilityUtil.java index 7354542bf3..57eb82ad51 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/SemconvStabilityUtil.java @@ -6,9 +6,6 @@ package io.opentelemetry.instrumentation.testing.junit.http; import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes; -import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes; import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.SemanticAttributes; import java.util.HashMap; @@ -20,39 +17,43 @@ public class SemconvStabilityUtil { static { addKey( - oldToNewMap, SemanticAttributes.NET_PROTOCOL_NAME, NetworkAttributes.NETWORK_PROTOCOL_NAME); + oldToNewMap, + SemanticAttributes.NET_PROTOCOL_NAME, + SemanticAttributes.NETWORK_PROTOCOL_NAME); addKey( oldToNewMap, SemanticAttributes.NET_PROTOCOL_VERSION, - NetworkAttributes.NETWORK_PROTOCOL_VERSION); - addKey(oldToNewMap, SemanticAttributes.NET_PEER_NAME, NetworkAttributes.SERVER_ADDRESS); - addKey(oldToNewMap, SemanticAttributes.NET_PEER_PORT, NetworkAttributes.SERVER_PORT); + SemanticAttributes.NETWORK_PROTOCOL_VERSION); + addKey(oldToNewMap, SemanticAttributes.NET_PEER_NAME, SemanticAttributes.SERVER_ADDRESS); + addKey(oldToNewMap, SemanticAttributes.NET_PEER_PORT, SemanticAttributes.SERVER_PORT); addKey( oldToNewMap, SemanticAttributes.NET_SOCK_PEER_ADDR, - NetworkAttributes.CLIENT_SOCKET_ADDRESS); + SemanticAttributes.CLIENT_SOCKET_ADDRESS); addKey( - oldToNewMap, SemanticAttributes.NET_SOCK_PEER_PORT, NetworkAttributes.CLIENT_SOCKET_PORT); - addKey(oldToNewMap, SemanticAttributes.HTTP_URL, UrlAttributes.URL_FULL); - addKey(oldToNewMap, SemanticAttributes.HTTP_METHOD, HttpAttributes.HTTP_REQUEST_METHOD); + oldToNewMap, SemanticAttributes.NET_SOCK_PEER_PORT, SemanticAttributes.CLIENT_SOCKET_PORT); + addKey(oldToNewMap, SemanticAttributes.HTTP_URL, SemanticAttributes.URL_FULL); + addKey(oldToNewMap, SemanticAttributes.HTTP_METHOD, SemanticAttributes.HTTP_REQUEST_METHOD); addKey( oldToNewMap, SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, - HttpAttributes.HTTP_REQUEST_BODY_SIZE); + SemanticAttributes.HTTP_REQUEST_BODY_SIZE); addKey( oldToNewMap, SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, - HttpAttributes.HTTP_RESPONSE_BODY_SIZE); + SemanticAttributes.HTTP_RESPONSE_BODY_SIZE); addKey( - oldToNewMap, SemanticAttributes.HTTP_STATUS_CODE, HttpAttributes.HTTP_RESPONSE_STATUS_CODE); - addKey(oldToNewMap, SemanticAttributes.NET_HOST_NAME, NetworkAttributes.SERVER_ADDRESS); - addKey(oldToNewMap, SemanticAttributes.NET_HOST_PORT, NetworkAttributes.SERVER_PORT); - addKey(oldToNewMap, SemanticAttributes.HTTP_CLIENT_IP, NetworkAttributes.CLIENT_ADDRESS); - addKey(oldToNewMap, SemanticAttributes.HTTP_SCHEME, UrlAttributes.URL_SCHEME); + oldToNewMap, + SemanticAttributes.HTTP_STATUS_CODE, + SemanticAttributes.HTTP_RESPONSE_STATUS_CODE); + addKey(oldToNewMap, SemanticAttributes.NET_HOST_NAME, SemanticAttributes.SERVER_ADDRESS); + addKey(oldToNewMap, SemanticAttributes.NET_HOST_PORT, SemanticAttributes.SERVER_PORT); + addKey(oldToNewMap, SemanticAttributes.HTTP_CLIENT_IP, SemanticAttributes.CLIENT_ADDRESS); + addKey(oldToNewMap, SemanticAttributes.HTTP_SCHEME, SemanticAttributes.URL_SCHEME); addKey( oldToNewMap, SemanticAttributes.NET_SOCK_HOST_ADDR, - NetworkAttributes.SERVER_SOCKET_ADDRESS); + SemanticAttributes.SERVER_SOCKET_ADDRESS); } private SemconvStabilityUtil() {}