Skip to content

Commit 54db0e9

Browse files
committed
Remove dependency on autoconfigure SemanticAttributes copy
1 parent 8e06ec7 commit 54db0e9

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java

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

44
package com.microsoft.applicationinsights.agent.internal.configuration;
55

6-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.SemanticAttributes;
76
import com.azure.monitor.opentelemetry.autoconfigure.implementation.statsbeat.RpAttachType;
87
import com.azure.monitor.opentelemetry.autoconfigure.implementation.utils.HostName;
98
import com.azure.monitor.opentelemetry.autoconfigure.implementation.utils.Strings;
@@ -22,6 +21,13 @@
2221
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.SamplingOverride;
2322
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
2423
import io.opentelemetry.api.common.AttributeKey;
24+
import io.opentelemetry.semconv.ClientAttributes;
25+
import io.opentelemetry.semconv.HttpAttributes;
26+
import io.opentelemetry.semconv.NetworkAttributes;
27+
import io.opentelemetry.semconv.ServerAttributes;
28+
import io.opentelemetry.semconv.UrlAttributes;
29+
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
30+
import io.opentelemetry.semconv.incubating.NetIncubatingAttributes;
2531
import java.io.IOException;
2632
import java.net.URL;
2733
import java.net.URLDecoder;
@@ -359,44 +365,44 @@ private static void supportTelemetryProcessorsOldSemConv(Configuration config) {
359365
private static String mapAttributeKey(String oldAttributeKey) {
360366
String result = null;
361367
// Common attributes across HTTP client and server spans
362-
if (oldAttributeKey.equals(SemanticAttributes.HTTP_METHOD.getKey())) {
363-
result = SemanticAttributes.HTTP_REQUEST_METHOD.getKey();
364-
} else if (oldAttributeKey.equals(SemanticAttributes.HTTP_STATUS_CODE.getKey())) {
365-
result = SemanticAttributes.HTTP_RESPONSE_STATUS_CODE.getKey();
368+
if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_METHOD.getKey())) {
369+
result = HttpAttributes.HTTP_REQUEST_METHOD.getKey();
370+
} else if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_STATUS_CODE.getKey())) {
371+
result = HttpAttributes.HTTP_RESPONSE_STATUS_CODE.getKey();
366372
} else if (oldAttributeKey.startsWith("http.request.header.")
367373
|| oldAttributeKey.startsWith("http.response.header.")) {
368374
result = oldAttributeKey.replace('_', '-');
369-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PROTOCOL_NAME.getKey())) {
370-
result = SemanticAttributes.NETWORK_PROTOCOL_NAME.getKey();
371-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PROTOCOL_VERSION.getKey())) {
372-
result = SemanticAttributes.NETWORK_PROTOCOL_VERSION.getKey();
373-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_SOCK_PEER_ADDR.getKey())) {
374-
result = SemanticAttributes.NETWORK_PEER_ADDRESS.getKey();
375-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_SOCK_PEER_PORT.getKey())) {
376-
result = SemanticAttributes.NETWORK_PEER_PORT.getKey();
375+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PROTOCOL_NAME.getKey())) {
376+
result = NetworkAttributes.NETWORK_PROTOCOL_NAME.getKey();
377+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PROTOCOL_VERSION.getKey())) {
378+
result = NetworkAttributes.NETWORK_PROTOCOL_VERSION.getKey();
379+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_SOCK_PEER_ADDR.getKey())) {
380+
result = NetworkAttributes.NETWORK_PEER_ADDRESS.getKey();
381+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_SOCK_PEER_PORT.getKey())) {
382+
result = NetworkAttributes.NETWORK_PEER_PORT.getKey();
377383
}
378384

379385
// HTTP client span attributes
380386
// http.url is handled via LazyHttpUrl
381-
if (oldAttributeKey.equals(SemanticAttributes.HTTP_RESEND_COUNT.getKey())) {
382-
result = SemanticAttributes.HTTP_REQUEST_RESEND_COUNT.getKey();
387+
if (oldAttributeKey.equals("http.resend_count")) {
388+
result = HttpAttributes.HTTP_REQUEST_RESEND_COUNT.getKey();
383389
// becomes available.
384-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PEER_NAME.getKey())) {
385-
result = SemanticAttributes.SERVER_ADDRESS.getKey();
386-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PEER_PORT.getKey())) {
387-
result = SemanticAttributes.SERVER_PORT.getKey();
390+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PEER_NAME.getKey())) {
391+
result = ServerAttributes.SERVER_ADDRESS.getKey();
392+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PEER_PORT.getKey())) {
393+
result = ServerAttributes.SERVER_PORT.getKey();
388394
}
389395

390396
// HTTP server span attributes
391397
// http.target is handled via LazyHttpTarget
392-
if (oldAttributeKey.equals(SemanticAttributes.HTTP_SCHEME.getKey())) {
393-
result = SemanticAttributes.URL_SCHEME.getKey();
394-
} else if (oldAttributeKey.equals(SemanticAttributes.HTTP_CLIENT_IP.getKey())) {
395-
result = SemanticAttributes.CLIENT_ADDRESS.getKey();
396-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_HOST_NAME.getKey())) {
397-
result = SemanticAttributes.SERVER_ADDRESS.getKey();
398-
} else if (oldAttributeKey.equals(SemanticAttributes.NET_HOST_PORT.getKey())) {
399-
result = SemanticAttributes.SERVER_PORT.getKey();
398+
if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_SCHEME.getKey())) {
399+
result = UrlAttributes.URL_SCHEME.getKey();
400+
} else if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_CLIENT_IP.getKey())) {
401+
result = ClientAttributes.CLIENT_ADDRESS.getKey();
402+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_HOST_NAME.getKey())) {
403+
result = ServerAttributes.SERVER_ADDRESS.getKey();
404+
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_HOST_PORT.getKey())) {
405+
result = ServerAttributes.SERVER_PORT.getKey();
400406
}
401407

402408
if (result == null) {

0 commit comments

Comments
 (0)