Skip to content

Commit ae25d48

Browse files
authored
Use new semconv constants (#9504)
1 parent d90485d commit ae25d48

File tree

42 files changed

+485
-638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+485
-638
lines changed

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientAttributesExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetClientAttributesExtractor;
1414
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.InternalNetworkAttributesExtractor;
1515
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.InternalServerAttributesExtractor;
16-
import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes;
1716
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
1817
import io.opentelemetry.instrumentation.api.internal.SpanKey;
1918
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
@@ -109,7 +108,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
109108

110109
String fullUrl = stripSensitiveData(getter.getUrlFull(request));
111110
if (SemconvStability.emitStableHttpSemconv()) {
112-
internalSet(attributes, UrlAttributes.URL_FULL, fullUrl);
111+
internalSet(attributes, SemanticAttributes.URL_FULL, fullUrl);
113112
}
114113
if (SemconvStability.emitOldHttpSemconv()) {
115114
internalSet(attributes, SemanticAttributes.HTTP_URL, fullUrl);

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesExtractor.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import io.opentelemetry.api.common.AttributesBuilder;
1515
import io.opentelemetry.context.Context;
1616
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
17-
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
1817
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
1918
import io.opentelemetry.semconv.SemanticAttributes;
2019
import java.util.HashSet;
@@ -53,10 +52,10 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
5352
String method = getter.getHttpRequestMethod(request);
5453
if (SemconvStability.emitStableHttpSemconv()) {
5554
if (method == null || knownMethods.contains(method)) {
56-
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method);
55+
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method);
5756
} else {
58-
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER);
59-
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
57+
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER);
58+
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
6059
}
6160
}
6261
if (SemconvStability.emitOldHttpSemconv()) {
@@ -83,7 +82,7 @@ public void onEnd(
8382

8483
Long requestBodySize = requestBodySize(request);
8584
if (SemconvStability.emitStableHttpSemconv()) {
86-
internalSet(attributes, HttpAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize);
85+
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize);
8786
}
8887
if (SemconvStability.emitOldHttpSemconv()) {
8988
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH, requestBodySize);
@@ -93,7 +92,7 @@ public void onEnd(
9392
Integer statusCode = getter.getHttpResponseStatusCode(request, response, error);
9493
if (statusCode != null && statusCode > 0) {
9594
if (SemconvStability.emitStableHttpSemconv()) {
96-
internalSet(attributes, HttpAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode);
95+
internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode);
9796
}
9897
if (SemconvStability.emitOldHttpSemconv()) {
9998
internalSet(attributes, SemanticAttributes.HTTP_STATUS_CODE, (long) statusCode);
@@ -102,7 +101,7 @@ public void onEnd(
102101

103102
Long responseBodySize = responseBodySize(request, response);
104103
if (SemconvStability.emitStableHttpSemconv()) {
105-
internalSet(attributes, HttpAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize);
104+
internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize);
106105
}
107106
if (SemconvStability.emitOldHttpSemconv()) {
108107
internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH, responseBodySize);

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMessageBodySizeUtil.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import io.opentelemetry.api.common.AttributeKey;
99
import io.opentelemetry.api.common.Attributes;
10-
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
1110
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
1211
import io.opentelemetry.semconv.SemanticAttributes;
1312
import javax.annotation.Nullable;
@@ -18,13 +17,13 @@ final class HttpMessageBodySizeUtil {
1817
private static final AttributeKey<Long> HTTP_REQUEST_BODY_SIZE =
1918
SemconvStability.emitOldHttpSemconv()
2019
? SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH
21-
: HttpAttributes.HTTP_REQUEST_BODY_SIZE;
20+
: SemanticAttributes.HTTP_REQUEST_BODY_SIZE;
2221

2322
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
2423
private static final AttributeKey<Long> HTTP_RESPONSE_BODY_SIZE =
2524
SemconvStability.emitOldHttpSemconv()
2625
? SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH
27-
: HttpAttributes.HTTP_RESPONSE_BODY_SIZE;
26+
: SemanticAttributes.HTTP_RESPONSE_BODY_SIZE;
2827

2928
@Nullable
3029
static Long getHttpRequestBodySize(Attributes... attributesList) {

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpMetricsAdvice.java

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder;
1414
import io.opentelemetry.extension.incubator.metrics.ExtendedLongHistogramBuilder;
1515
import io.opentelemetry.extension.incubator.metrics.ExtendedLongUpDownCounterBuilder;
16-
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
17-
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes;
18-
import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes;
1916
import io.opentelemetry.semconv.SemanticAttributes;
2017

2118
final class HttpMetricsAdvice {
@@ -29,13 +26,13 @@ static void applyStableClientDurationAdvice(DoubleHistogramBuilder builder) {
2926
advice ->
3027
advice.setAttributes(
3128
asList(
32-
HttpAttributes.HTTP_REQUEST_METHOD,
33-
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
34-
NetworkAttributes.NETWORK_PROTOCOL_NAME,
35-
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
36-
NetworkAttributes.SERVER_ADDRESS,
37-
NetworkAttributes.SERVER_PORT,
38-
NetworkAttributes.SERVER_SOCKET_ADDRESS)));
29+
SemanticAttributes.HTTP_REQUEST_METHOD,
30+
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
31+
SemanticAttributes.NETWORK_PROTOCOL_NAME,
32+
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
33+
SemanticAttributes.SERVER_ADDRESS,
34+
SemanticAttributes.SERVER_PORT,
35+
SemanticAttributes.SERVER_SOCKET_ADDRESS)));
3936
}
4037

4138
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@@ -68,13 +65,13 @@ static void applyClientRequestSizeAdvice(LongHistogramBuilder builder) {
6865
advice.setAttributes(
6966
asList(
7067
// stable attributes
71-
HttpAttributes.HTTP_REQUEST_METHOD,
72-
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
73-
NetworkAttributes.NETWORK_PROTOCOL_NAME,
74-
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
75-
NetworkAttributes.SERVER_ADDRESS,
76-
NetworkAttributes.SERVER_PORT,
77-
NetworkAttributes.SERVER_SOCKET_ADDRESS,
68+
SemanticAttributes.HTTP_REQUEST_METHOD,
69+
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
70+
SemanticAttributes.NETWORK_PROTOCOL_NAME,
71+
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
72+
SemanticAttributes.SERVER_ADDRESS,
73+
SemanticAttributes.SERVER_PORT,
74+
SemanticAttributes.SERVER_SOCKET_ADDRESS,
7875
// old attributes
7976
SemanticAttributes.HTTP_METHOD,
8077
SemanticAttributes.HTTP_STATUS_CODE,
@@ -95,11 +92,11 @@ static void applyStableServerDurationAdvice(DoubleHistogramBuilder builder) {
9592
advice.setAttributes(
9693
asList(
9794
SemanticAttributes.HTTP_ROUTE,
98-
HttpAttributes.HTTP_REQUEST_METHOD,
99-
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
100-
NetworkAttributes.NETWORK_PROTOCOL_NAME,
101-
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
102-
UrlAttributes.URL_SCHEME)));
95+
SemanticAttributes.HTTP_REQUEST_METHOD,
96+
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
97+
SemanticAttributes.NETWORK_PROTOCOL_NAME,
98+
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
99+
SemanticAttributes.URL_SCHEME)));
103100
}
104101

105102
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
@@ -134,11 +131,11 @@ static void applyServerRequestSizeAdvice(LongHistogramBuilder builder) {
134131
asList(
135132
// stable attributes
136133
SemanticAttributes.HTTP_ROUTE,
137-
HttpAttributes.HTTP_REQUEST_METHOD,
138-
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
139-
NetworkAttributes.NETWORK_PROTOCOL_NAME,
140-
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
141-
UrlAttributes.URL_SCHEME,
134+
SemanticAttributes.HTTP_REQUEST_METHOD,
135+
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
136+
SemanticAttributes.NETWORK_PROTOCOL_NAME,
137+
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
138+
SemanticAttributes.URL_SCHEME,
142139
// old attributes
143140
SemanticAttributes.HTTP_SCHEME,
144141
SemanticAttributes.HTTP_ROUTE,
@@ -166,8 +163,8 @@ static void applyServerActiveRequestsAdvice(LongUpDownCounterBuilder builder) {
166163
SemanticAttributes.NET_HOST_NAME,
167164
SemanticAttributes.NET_HOST_PORT,
168165
// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md#metric-httpserveractive_requests
169-
HttpAttributes.HTTP_REQUEST_METHOD,
170-
UrlAttributes.URL_SCHEME)));
166+
SemanticAttributes.HTTP_REQUEST_METHOD,
167+
SemanticAttributes.URL_SCHEME)));
171168
}
172169

173170
private HttpMetricsAdvice() {}

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/internal/HttpAttributes.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalClientAttributesExtractor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public void onStart(AttributesBuilder attributes, REQUEST request) {
3939
AddressAndPort clientAddressAndPort = extractClientAddressAndPort(request);
4040

4141
if (emitStableUrlAttributes) {
42-
internalSet(attributes, NetworkAttributes.CLIENT_ADDRESS, clientAddressAndPort.address);
42+
internalSet(attributes, SemanticAttributes.CLIENT_ADDRESS, clientAddressAndPort.address);
4343
if (clientAddressAndPort.port != null && clientAddressAndPort.port > 0) {
44-
internalSet(attributes, NetworkAttributes.CLIENT_PORT, (long) clientAddressAndPort.port);
44+
internalSet(attributes, SemanticAttributes.CLIENT_PORT, (long) clientAddressAndPort.port);
4545
}
4646
}
4747
if (emitOldHttpAttributes) {
@@ -57,7 +57,7 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
5757

5858
if (clientSocketAddress != null && !clientSocketAddress.equals(clientAddressAndPort.address)) {
5959
if (emitStableUrlAttributes) {
60-
internalSet(attributes, NetworkAttributes.CLIENT_SOCKET_ADDRESS, clientSocketAddress);
60+
internalSet(attributes, SemanticAttributes.CLIENT_SOCKET_ADDRESS, clientSocketAddress);
6161
}
6262
if (emitOldHttpAttributes) {
6363
internalSet(attributes, SemanticAttributes.NET_SOCK_PEER_ADDR, clientSocketAddress);
@@ -66,7 +66,7 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
6666
if (clientSocketPort != null && clientSocketPort > 0) {
6767
if (emitStableUrlAttributes) {
6868
if (!clientSocketPort.equals(clientAddressAndPort.port)) {
69-
internalSet(attributes, NetworkAttributes.CLIENT_SOCKET_PORT, (long) clientSocketPort);
69+
internalSet(attributes, SemanticAttributes.CLIENT_SOCKET_PORT, (long) clientSocketPort);
7070
}
7171
}
7272
if (emitOldHttpAttributes) {

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalNetworkAttributesExtractor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
4444
String transport = lowercase(getter.getNetworkTransport(request, response));
4545
if (networkTransportFilter.shouldAddNetworkTransport(
4646
protocolName, protocolVersion, transport)) {
47-
internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport);
47+
internalSet(attributes, SemanticAttributes.NETWORK_TRANSPORT, transport);
4848
}
4949
internalSet(
5050
attributes,
51-
NetworkAttributes.NETWORK_TYPE,
51+
SemanticAttributes.NETWORK_TYPE,
5252
lowercase(getter.getNetworkType(request, response)));
53-
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName);
54-
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
53+
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_NAME, protocolName);
54+
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
5555
}
5656
if (emitOldHttpAttributes) {
5757
// net.transport and net.sock.family are not 1:1 convertible with network.transport and

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/InternalServerAttributesExtractor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void onStart(AttributesBuilder attributes, REQUEST request) {
4949
AddressAndPort serverAddressAndPort = extractServerAddressAndPort(request);
5050

5151
if (emitStableUrlAttributes) {
52-
internalSet(attributes, NetworkAttributes.SERVER_ADDRESS, serverAddressAndPort.address);
52+
internalSet(attributes, SemanticAttributes.SERVER_ADDRESS, serverAddressAndPort.address);
5353
}
5454
if (emitOldHttpAttributes) {
5555
internalSet(attributes, oldSemconvMode.address, serverAddressAndPort.address);
@@ -59,7 +59,7 @@ public void onStart(AttributesBuilder attributes, REQUEST request) {
5959
&& serverAddressAndPort.port > 0
6060
&& captureServerPortCondition.test(serverAddressAndPort.port, request)) {
6161
if (emitStableUrlAttributes) {
62-
internalSet(attributes, NetworkAttributes.SERVER_PORT, (long) serverAddressAndPort.port);
62+
internalSet(attributes, SemanticAttributes.SERVER_PORT, (long) serverAddressAndPort.port);
6363
}
6464
if (emitOldHttpAttributes) {
6565
internalSet(attributes, oldSemconvMode.port, (long) serverAddressAndPort.port);
@@ -73,7 +73,7 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
7373
String serverSocketAddress = getter.getServerSocketAddress(request, response);
7474
if (serverSocketAddress != null && !serverSocketAddress.equals(serverAddressAndPort.address)) {
7575
if (emitStableUrlAttributes && captureServerSocketAttributes) {
76-
internalSet(attributes, NetworkAttributes.SERVER_SOCKET_ADDRESS, serverSocketAddress);
76+
internalSet(attributes, SemanticAttributes.SERVER_SOCKET_ADDRESS, serverSocketAddress);
7777
}
7878
if (emitOldHttpAttributes) {
7979
internalSet(attributes, oldSemconvMode.socketAddress, serverSocketAddress);
@@ -85,7 +85,7 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
8585
&& serverSocketPort > 0
8686
&& !serverSocketPort.equals(serverAddressAndPort.port)) {
8787
if (emitStableUrlAttributes && captureServerSocketAttributes) {
88-
internalSet(attributes, NetworkAttributes.SERVER_SOCKET_PORT, (long) serverSocketPort);
88+
internalSet(attributes, SemanticAttributes.SERVER_SOCKET_PORT, (long) serverSocketPort);
8989
}
9090
if (emitOldHttpAttributes) {
9191
internalSet(attributes, oldSemconvMode.socketPort, (long) serverSocketPort);
@@ -95,7 +95,7 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO
9595
String serverSocketDomain = getter.getServerSocketDomain(request, response);
9696
if (serverSocketDomain != null && !serverSocketDomain.equals(serverAddressAndPort.address)) {
9797
if (emitStableUrlAttributes && captureServerSocketAttributes) {
98-
internalSet(attributes, NetworkAttributes.SERVER_SOCKET_DOMAIN, serverSocketDomain);
98+
internalSet(attributes, SemanticAttributes.SERVER_SOCKET_DOMAIN, serverSocketDomain);
9999
}
100100
if (emitOldHttpAttributes && oldSemconvMode.socketDomain != null) {
101101
internalSet(attributes, oldSemconvMode.socketDomain, serverSocketDomain);

instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/internal/NetworkAttributes.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)