From 8b223f8abe8a84e64ee52a23da6e9fe020180b99 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 13 Oct 2023 09:41:37 -0700 Subject: [PATCH] Revert "Move to io.opentelemetry.semconv:opentelemetry-semconv (#1050)" (#1070) --- aws-xray/build.gradle.kts | 9 +- .../awsxray/AwsMetricAttributeGenerator.java | 76 ++++++++-------- .../awsxray/AwsSpanMetricsProcessor.java | 4 +- .../contrib/awsxray/SamplingRuleApplier.java | 18 +--- .../AwsMetricAttributeGeneratorTest.java | 90 +++++++++---------- .../awsxray/AwsSpanMetricsProcessorTest.java | 12 +-- .../AwsXrayRemoteSamplerProviderTest.java | 2 +- .../awsxray/SamplingRuleApplierTest.java | 88 +++++++++--------- 8 files changed, 147 insertions(+), 152 deletions(-) diff --git a/aws-xray/build.gradle.kts b/aws-xray/build.gradle.kts index bfbb14504..ccec9d52f 100644 --- a/aws-xray/build.gradle.kts +++ b/aws-xray/build.gradle.kts @@ -13,7 +13,7 @@ dependencies { compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") implementation("com.squareup.okhttp3:okhttp") - implementation("io.opentelemetry.semconv:opentelemetry-semconv") + implementation("io.opentelemetry:opentelemetry-semconv") annotationProcessor("com.google.auto.service:auto-service") testImplementation("com.google.auto.service:auto-service") @@ -45,3 +45,10 @@ testing { } } } + +configurations.all { + resolutionStrategy { + // TODO this module still needs to be updated to the latest semconv + force("io.opentelemetry:opentelemetry-semconv:1.28.0-alpha") + } +} diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java index 69f2e63a3..bf55d061e 100644 --- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java +++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGenerator.java @@ -15,24 +15,24 @@ import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_SPAN_KIND; import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_STREAM_NAME; import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_TABLE_NAME; -import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.DB_OPERATION; -import static io.opentelemetry.semconv.SemanticAttributes.DB_SYSTEM; -import static io.opentelemetry.semconv.SemanticAttributes.FAAS_INVOKED_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.FAAS_TRIGGER; -import static io.opentelemetry.semconv.SemanticAttributes.GRAPHQL_OPERATION_TYPE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_OPERATION; -import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_SYSTEM; -import static io.opentelemetry.semconv.SemanticAttributes.PEER_SERVICE; -import static io.opentelemetry.semconv.SemanticAttributes.RPC_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.RPC_SERVICE; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_ADDRESS; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_SOCKET_ADDRESS; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_SOCKET_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.URL_FULL; -import static io.opentelemetry.semconv.SemanticAttributes.URL_PATH; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DB_OPERATION; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DB_SYSTEM; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.FAAS_INVOKED_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.FAAS_TRIGGER; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.GRAPHQL_OPERATION_TYPE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_METHOD; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_TARGET; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_URL; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_OPERATION; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_SYSTEM; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_ADDR; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_PORT; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.PEER_SERVICE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_METHOD; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_SERVICE; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -40,8 +40,8 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.data.SpanData; -import io.opentelemetry.semconv.ResourceAttributes; -import io.opentelemetry.semconv.SemanticAttributes; +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.net.MalformedURLException; import java.net.URL; import java.util.Optional; @@ -156,8 +156,8 @@ private static boolean isValidOperation(SpanData span) { if (operation == null || operation.equals(UNKNOWN_OPERATION)) { return false; } - if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); + if (isKeyPresent(span, HTTP_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_METHOD); return !operation.equals(httpMethod); } return true; @@ -260,15 +260,15 @@ private static void setRemoteServiceAndOperation(SpanData span, AttributesBuilde */ private static String generateIngressOperation(SpanData span) { String operation = UNKNOWN_OPERATION; - if (isKeyPresent(span, URL_PATH)) { - String httpTarget = span.getAttributes().get(URL_PATH); + if (isKeyPresent(span, HTTP_TARGET)) { + String httpTarget = span.getAttributes().get(HTTP_TARGET); // get the first part from API path string as operation value // the more levels/parts we get from API path the higher chance for getting high cardinality // data if (httpTarget != null) { operation = extractApiPathValue(httpTarget); - if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); + if (isKeyPresent(span, HTTP_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_METHOD); if (httpMethod != null) { operation = httpMethod + " " + operation; } @@ -284,8 +284,8 @@ private static String generateIngressOperation(SpanData span) { */ private static String generateRemoteOperation(SpanData span) { String remoteOperation = UNKNOWN_REMOTE_OPERATION; - if (isKeyPresent(span, URL_FULL)) { - String httpUrl = span.getAttributes().get(URL_FULL); + if (isKeyPresent(span, HTTP_URL)) { + String httpUrl = span.getAttributes().get(HTTP_URL); try { URL url; if (httpUrl != null) { @@ -296,8 +296,8 @@ private static String generateRemoteOperation(SpanData span) { logger.log(Level.FINEST, "invalid http.url attribute: ", httpUrl); } } - if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); + if (isKeyPresent(span, HTTP_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_METHOD); remoteOperation = httpMethod + " " + remoteOperation; } if (remoteOperation.equals(UNKNOWN_REMOTE_OPERATION)) { @@ -325,16 +325,16 @@ private static String extractApiPathValue(String httpTarget) { private static String generateRemoteService(SpanData span) { String remoteService = UNKNOWN_REMOTE_SERVICE; - if (isKeyPresent(span, SERVER_ADDRESS)) { - remoteService = getRemoteService(span, SERVER_ADDRESS); - if (isKeyPresent(span, SERVER_PORT)) { - Long port = span.getAttributes().get(SERVER_PORT); + if (isKeyPresent(span, NET_PEER_NAME)) { + remoteService = getRemoteService(span, NET_PEER_NAME); + if (isKeyPresent(span, NET_PEER_PORT)) { + Long port = span.getAttributes().get(NET_PEER_PORT); remoteService += ":" + port; } - } else if (isKeyPresent(span, SERVER_SOCKET_ADDRESS)) { - remoteService = getRemoteService(span, SERVER_SOCKET_ADDRESS); - if (isKeyPresent(span, SERVER_SOCKET_PORT)) { - Long port = span.getAttributes().get(SERVER_SOCKET_PORT); + } else if (isKeyPresent(span, NET_SOCK_PEER_ADDR)) { + remoteService = getRemoteService(span, NET_SOCK_PEER_ADDR); + if (isKeyPresent(span, NET_SOCK_PEER_PORT)) { + Long port = span.getAttributes().get(NET_SOCK_PEER_PORT); remoteService += ":" + port; } } else { diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessor.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessor.java index 7dec5d0ac..fb2c2a103 100644 --- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessor.java +++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessor.java @@ -5,7 +5,7 @@ package io.opentelemetry.contrib.awsxray; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_STATUS_CODE; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.DoubleHistogram; @@ -107,7 +107,7 @@ public boolean isEndRequired() { } private void recordErrorOrFault(SpanData spanData, Attributes attributes) { - Long httpStatusCode = spanData.getAttributes().get(HTTP_RESPONSE_STATUS_CODE); + Long httpStatusCode = spanData.getAttributes().get(HTTP_STATUS_CODE); if (httpStatusCode == null) { httpStatusCode = getAwsStatusCode(spanData); diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java index 5f3d9a8bc..1ef8abf50 100644 --- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java +++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplier.java @@ -17,8 +17,8 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import io.opentelemetry.sdk.trace.samplers.SamplingDecision; import io.opentelemetry.sdk.trace.samplers.SamplingResult; -import io.opentelemetry.semconv.ResourceAttributes; -import io.opentelemetry.semconv.SemanticAttributes; +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.time.Duration; import java.util.Collections; import java.util.Date; @@ -162,25 +162,13 @@ boolean matches(Attributes attributes, Resource resource) { String host = null; for (Map.Entry, Object> entry : attributes.asMap().entrySet()) { - if (entry.getKey().equals(SemanticAttributes.URL_PATH)) { + if (entry.getKey().equals(SemanticAttributes.HTTP_TARGET)) { httpTarget = (String) entry.getValue(); - } else if (entry.getKey().equals(SemanticAttributes.HTTP_TARGET)) { - // TODO remove support for deprecated http.target attribute - httpTarget = (String) entry.getValue(); - } else if (entry.getKey().equals(SemanticAttributes.URL_FULL)) { - httpUrl = (String) entry.getValue(); } else if (entry.getKey().equals(SemanticAttributes.HTTP_URL)) { - // TODO remove support for deprecated http.url attribute httpUrl = (String) entry.getValue(); - } else if (entry.getKey().equals(SemanticAttributes.HTTP_REQUEST_METHOD)) { - httpMethod = (String) entry.getValue(); } else if (entry.getKey().equals(SemanticAttributes.HTTP_METHOD)) { - // TODO remove support for deprecated http.method attribute httpMethod = (String) entry.getValue(); - } else if (entry.getKey().equals(SemanticAttributes.SERVER_ADDRESS)) { - host = (String) entry.getValue(); } else if (entry.getKey().equals(SemanticAttributes.NET_HOST_NAME)) { - // TODO remove support for deprecated net.host.name attribute host = (String) entry.getValue(); } else if (entry.getKey().equals(SemanticAttributes.HTTP_HOST)) { // TODO (trask) remove support for deprecated http.host attribute diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGeneratorTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGeneratorTest.java index 256be20ac..b1df48daa 100644 --- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGeneratorTest.java +++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsMetricAttributeGeneratorTest.java @@ -15,25 +15,25 @@ import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_SPAN_KIND; import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_STREAM_NAME; import static io.opentelemetry.contrib.awsxray.AwsAttributeKeys.AWS_TABLE_NAME; -import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.DB_OPERATION; -import static io.opentelemetry.semconv.SemanticAttributes.DB_SYSTEM; -import static io.opentelemetry.semconv.SemanticAttributes.FAAS_INVOKED_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.FAAS_INVOKED_PROVIDER; -import static io.opentelemetry.semconv.SemanticAttributes.FAAS_TRIGGER; -import static io.opentelemetry.semconv.SemanticAttributes.GRAPHQL_OPERATION_TYPE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_OPERATION; -import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_SYSTEM; -import static io.opentelemetry.semconv.SemanticAttributes.PEER_SERVICE; -import static io.opentelemetry.semconv.SemanticAttributes.RPC_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.RPC_SERVICE; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_ADDRESS; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_SOCKET_ADDRESS; -import static io.opentelemetry.semconv.SemanticAttributes.SERVER_SOCKET_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.URL_FULL; -import static io.opentelemetry.semconv.SemanticAttributes.URL_PATH; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DB_OPERATION; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DB_SYSTEM; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.FAAS_INVOKED_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.FAAS_INVOKED_PROVIDER; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.FAAS_TRIGGER; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.GRAPHQL_OPERATION_TYPE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_METHOD; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_TARGET; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_URL; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_OPERATION; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_SYSTEM; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_ADDR; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_PEER_PORT; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.PEER_SERVICE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_METHOD; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_SERVICE; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -170,7 +170,7 @@ public void testServerSpanWithNullSpanName() { public void testServerSpanWithSpanNameAsHttpMethod() { updateResourceWithServiceName(); when(spanDataMock.getName()).thenReturn("GET"); - mockAttribute(HTTP_REQUEST_METHOD, "GET"); + mockAttribute(HTTP_METHOD, "GET"); Attributes expectedAttributes = Attributes.of( @@ -178,15 +178,15 @@ public void testServerSpanWithSpanNameAsHttpMethod() { AWS_LOCAL_SERVICE, SERVICE_NAME_VALUE, AWS_LOCAL_OPERATION, UNKNOWN_OPERATION); validateAttributesProducedForSpanOfKind(expectedAttributes, SpanKind.SERVER); - mockAttribute(HTTP_REQUEST_METHOD, null); + mockAttribute(HTTP_METHOD, null); } @Test public void testServerSpanWithSpanNameWithHttpTarget() { updateResourceWithServiceName(); when(spanDataMock.getName()).thenReturn("POST"); - mockAttribute(HTTP_REQUEST_METHOD, "POST"); - mockAttribute(URL_PATH, "/payment/123"); + mockAttribute(HTTP_METHOD, "POST"); + mockAttribute(HTTP_TARGET, "/payment/123"); Attributes expectedAttributes = Attributes.of( @@ -197,8 +197,8 @@ public void testServerSpanWithSpanNameWithHttpTarget() { AWS_LOCAL_OPERATION, "POST /payment"); validateAttributesProducedForSpanOfKind(expectedAttributes, SpanKind.SERVER); - mockAttribute(HTTP_REQUEST_METHOD, null); - mockAttribute(URL_PATH, null); + mockAttribute(HTTP_METHOD, null); + mockAttribute(HTTP_TARGET, null); } @Test @@ -283,44 +283,44 @@ public void testRemoteAttributesCombinations() { mockAttribute(GRAPHQL_OPERATION_TYPE, null); // Validate behaviour of extracting Remote Service from net.peer.name - mockAttribute(SERVER_ADDRESS, "www.example.com"); + mockAttribute(NET_PEER_NAME, "www.example.com"); validateExpectedRemoteAttributes("www.example.com", UNKNOWN_REMOTE_OPERATION); - mockAttribute(SERVER_ADDRESS, null); + mockAttribute(NET_PEER_NAME, null); // Validate behaviour of extracting Remote Service from net.peer.name and net.peer.port - mockAttribute(SERVER_ADDRESS, "192.168.0.0"); - mockAttribute(SERVER_PORT, 8081L); + mockAttribute(NET_PEER_NAME, "192.168.0.0"); + mockAttribute(NET_PEER_PORT, 8081L); validateExpectedRemoteAttributes("192.168.0.0:8081", UNKNOWN_REMOTE_OPERATION); - mockAttribute(SERVER_ADDRESS, null); - mockAttribute(SERVER_PORT, null); + mockAttribute(NET_PEER_NAME, null); + mockAttribute(NET_PEER_PORT, null); // Validate behaviour of extracting Remote Service from net.peer.socket.addr - mockAttribute(SERVER_SOCKET_ADDRESS, "www.example.com"); + mockAttribute(NET_SOCK_PEER_ADDR, "www.example.com"); validateExpectedRemoteAttributes("www.example.com", UNKNOWN_REMOTE_OPERATION); - mockAttribute(SERVER_SOCKET_ADDRESS, null); + mockAttribute(NET_SOCK_PEER_ADDR, null); // Validate behaviour of extracting Remote Service from net.peer.socket.addr and // net.sock.peer.port - mockAttribute(SERVER_SOCKET_ADDRESS, "192.168.0.0"); - mockAttribute(SERVER_SOCKET_PORT, 8081L); + mockAttribute(NET_SOCK_PEER_ADDR, "192.168.0.0"); + mockAttribute(NET_SOCK_PEER_PORT, 8081L); validateExpectedRemoteAttributes("192.168.0.0:8081", UNKNOWN_REMOTE_OPERATION); - mockAttribute(SERVER_SOCKET_ADDRESS, null); - mockAttribute(SERVER_SOCKET_PORT, null); + mockAttribute(NET_SOCK_PEER_ADDR, null); + mockAttribute(NET_SOCK_PEER_PORT, null); // Validate behavior of Remote Operation from HttpTarget - with 1st api part, then remove it - mockAttribute(URL_FULL, "http://www.example.com/payment/123"); + mockAttribute(HTTP_URL, "http://www.example.com/payment/123"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, "/payment"); - mockAttribute(URL_FULL, null); + mockAttribute(HTTP_URL, null); // Validate behavior of Remote Operation from HttpTarget - without 1st api part, then remove it - mockAttribute(URL_FULL, "http://www.example.com"); + mockAttribute(HTTP_URL, "http://www.example.com"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, "/"); - mockAttribute(URL_FULL, null); + mockAttribute(HTTP_URL, null); // Validate behavior of Remote Operation from HttpTarget - invalid url, then remove it - mockAttribute(URL_FULL, "abc"); + mockAttribute(HTTP_URL, "abc"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, UNKNOWN_REMOTE_OPERATION); - mockAttribute(URL_FULL, null); + mockAttribute(HTTP_URL, null); // Validate behaviour of Peer service attribute, then remove it. mockAttribute(PEER_SERVICE, "Peer service"); @@ -338,8 +338,8 @@ public void testPeerServiceDoesOverrideOtherRemoteServices() { validatePeerServiceDoesOverride(FAAS_INVOKED_PROVIDER); validatePeerServiceDoesOverride(MESSAGING_SYSTEM); validatePeerServiceDoesOverride(GRAPHQL_OPERATION_TYPE); - validatePeerServiceDoesOverride(SERVER_ADDRESS); - validatePeerServiceDoesOverride(SERVER_SOCKET_ADDRESS); + validatePeerServiceDoesOverride(NET_PEER_NAME); + validatePeerServiceDoesOverride(NET_SOCK_PEER_ADDR); // Actually testing that peer service overrides "UnknownRemoteService". validatePeerServiceDoesOverride(AttributeKey.stringKey("unknown.service.key")); } diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessorTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessorTest.java index 77188a606..c2109b267 100644 --- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessorTest.java +++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsSpanMetricsProcessorTest.java @@ -5,7 +5,7 @@ package io.opentelemetry.contrib.awsxray; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_STATUS_CODE; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -141,7 +141,7 @@ public void testOnEndMetricsGenerationWithoutSpanAttributes() { @Test public void testOnEndMetricsGenerationWithoutMetricAttributes() { - Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 500L); + Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 500L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Attributes metricAttributes = buildMetricAttributes(CONTAINS_NO_ATTRIBUTES); configureMocksForOnEnd(readableSpanMock, metricAttributes); @@ -154,7 +154,7 @@ public void testOnEndMetricsGenerationWithoutMetricAttributes() { @Test public void testOnEndMetricsGenerationWithoutEndRequired() { - Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 500L); + Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 500L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES); configureMocksForOnEnd(readableSpanMock, metricAttributes); @@ -167,7 +167,7 @@ public void testOnEndMetricsGenerationWithoutEndRequired() { @Test public void testOnEndMetricsGenerationWithLatency() { - Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 200L); + Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 200L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES); configureMocksForOnEnd(readableSpanMock, metricAttributes); @@ -245,7 +245,7 @@ private static ReadableSpan buildReadableSpanMock(Attributes spanAttributes) { private static ReadableSpan buildReadableSpanWithThrowableMock(Throwable throwable) { // config http status code as null - Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, null); + Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, null); ReadableSpan readableSpanMock = mock(ReadableSpan.class); SpanData mockSpanData = mock(SpanData.class); InstrumentationScopeInfo awsSdkScopeInfo = @@ -280,7 +280,7 @@ private void configureMocksForOnEnd(ReadableSpan readableSpanMock, Attributes me private void validateMetricsGeneratedForHttpStatusCode( Long httpStatusCode, ExpectedStatusMetric expectedStatusMetric) { - Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, httpStatusCode); + Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, httpStatusCode); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Attributes metricAttributes = buildMetricAttributes(CONTAINS_ATTRIBUTES); configureMocksForOnEnd(readableSpanMock, metricAttributes); diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.java index 046b7cd11..5a51318f2 100644 --- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.java +++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.java @@ -9,7 +9,7 @@ import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; import io.opentelemetry.sdk.trace.SdkTracerProvider; -import io.opentelemetry.semconv.ResourceAttributes; +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java index e783c5a10..6bb6e82a4 100644 --- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java +++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/SamplingRuleApplierTest.java @@ -5,7 +5,7 @@ package io.opentelemetry.contrib.awsxray; -import static io.opentelemetry.semconv.ResourceAttributes.SERVICE_NAME; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -22,8 +22,8 @@ import io.opentelemetry.sdk.testing.time.TestClock; import io.opentelemetry.sdk.trace.samplers.SamplingDecision; import io.opentelemetry.sdk.trace.samplers.SamplingResult; -import io.opentelemetry.semconv.ResourceAttributes; -import io.opentelemetry.semconv.SemanticAttributes; +import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.io.IOException; import java.io.UncheckedIOException; import java.time.Duration; @@ -61,9 +61,9 @@ class ExactMatch { private final Attributes attributes = Attributes.builder() - .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") - .put(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io") - .put(SemanticAttributes.URL_PATH, "/instrument-me") + .put(SemanticAttributes.HTTP_METHOD, "GET") + .put(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-me") .put(AttributeKey.stringKey("animal"), "cat") .put(AttributeKey.longKey("speed"), 10) .build(); @@ -109,8 +109,8 @@ void matches() { assertThat( applier.matches( attributes.toBuilder() - .remove(SemanticAttributes.URL_PATH) - .put(SemanticAttributes.URL_FULL, "scheme://host:port/instrument-me") + .remove(SemanticAttributes.HTTP_TARGET) + .put(SemanticAttributes.HTTP_URL, "scheme://host:port/instrument-me") .build(), resource)) .isTrue(); @@ -133,7 +133,7 @@ void serviceNameNullNotMatch() { @Test void methodNotMatch() { Attributes attributes = - this.attributes.toBuilder().put(SemanticAttributes.HTTP_REQUEST_METHOD, "POST").build(); + this.attributes.toBuilder().put(SemanticAttributes.HTTP_METHOD, "POST").build(); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -143,7 +143,7 @@ void hostNotMatch() { // wildcard. Attributes attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentelemetryfio") + .put(SemanticAttributes.NET_HOST_NAME, "opentelemetryfio") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -151,18 +151,20 @@ void hostNotMatch() { @Test void pathNotMatch() { Attributes attributes = - this.attributes.toBuilder().put(SemanticAttributes.URL_PATH, "/instrument-you").build(); + this.attributes.toBuilder() + .put(SemanticAttributes.HTTP_TARGET, "/instrument-you") + .build(); assertThat(applier.matches(attributes, resource)).isFalse(); attributes = this.attributes.toBuilder() - .remove(SemanticAttributes.URL_PATH) - .put(SemanticAttributes.URL_FULL, "scheme://host:port/instrument-you") + .remove(SemanticAttributes.HTTP_TARGET) + .put(SemanticAttributes.HTTP_URL, "scheme://host:port/instrument-you") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); attributes = this.attributes.toBuilder() - .remove(SemanticAttributes.URL_PATH) - .put(SemanticAttributes.URL_FULL, "scheme://host:port") + .remove(SemanticAttributes.HTTP_TARGET) + .put(SemanticAttributes.HTTP_URL, "scheme://host:port") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); @@ -170,8 +172,8 @@ void pathNotMatch() { // present. attributes = this.attributes.toBuilder() - .remove(SemanticAttributes.URL_PATH) - .put(SemanticAttributes.URL_FULL, "host:port/instrument-me") + .remove(SemanticAttributes.HTTP_TARGET) + .put(SemanticAttributes.HTTP_URL, "host:port/instrument-me") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -234,9 +236,9 @@ class WildcardMatch { private final Attributes attributes = Attributes.builder() - .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") - .put(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io") - .put(SemanticAttributes.URL_PATH, "/instrument-me?foo=bar&cat=meow") + .put(SemanticAttributes.HTTP_METHOD, "GET") + .put(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-me?foo=bar&cat=meow") .put(AttributeKey.stringKey("animal"), "cat") .put(AttributeKey.longKey("speed"), 10) .build(); @@ -308,24 +310,22 @@ void serviceNameNotMatch() { @Test void methodMatches() { Attributes attributes = - this.attributes.toBuilder() - .put(SemanticAttributes.HTTP_REQUEST_METHOD, "BADGETGOOD") - .build(); + this.attributes.toBuilder().put(SemanticAttributes.HTTP_METHOD, "BADGETGOOD").build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = - this.attributes.toBuilder().put(SemanticAttributes.HTTP_REQUEST_METHOD, "BADGET").build(); + this.attributes.toBuilder().put(SemanticAttributes.HTTP_METHOD, "BADGET").build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = - this.attributes.toBuilder().put(SemanticAttributes.HTTP_REQUEST_METHOD, "GETGET").build(); + this.attributes.toBuilder().put(SemanticAttributes.HTTP_METHOD, "GETGET").build(); assertThat(applier.matches(attributes, resource)).isTrue(); } @Test void methodNotMatch() { Attributes attributes = - this.attributes.toBuilder().put(SemanticAttributes.HTTP_REQUEST_METHOD, "POST").build(); + this.attributes.toBuilder().put(SemanticAttributes.HTTP_METHOD, "POST").build(); assertThat(applier.matches(attributes, resource)).isFalse(); - attributes = removeAttribute(this.attributes, SemanticAttributes.HTTP_REQUEST_METHOD); + attributes = removeAttribute(this.attributes, SemanticAttributes.HTTP_METHOD); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -333,27 +333,27 @@ void methodNotMatch() { void hostMatches() { Attributes attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "alpha.opentelemetry.io") + .put(SemanticAttributes.NET_HOST_NAME, "alpha.opentelemetry.io") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opfdnqtelemetry.io") + .put(SemanticAttributes.NET_HOST_NAME, "opfdnqtelemetry.io") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentglemetry.io") + .put(SemanticAttributes.NET_HOST_NAME, "opentglemetry.io") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentglemry.io") + .put(SemanticAttributes.NET_HOST_NAME, "opentglemry.io") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentglemrz.io") + .put(SemanticAttributes.NET_HOST_NAME, "opentglemrz.io") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); } @@ -362,20 +362,20 @@ void hostMatches() { void hostNotMatch() { Attributes attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentelemetryfio") + .put(SemanticAttributes.NET_HOST_NAME, "opentelemetryfio") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "opentgalemetry.io") + .put(SemanticAttributes.NET_HOST_NAME, "opentgalemetry.io") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.SERVER_ADDRESS, "alpha.oentelemetry.io") + .put(SemanticAttributes.NET_HOST_NAME, "alpha.oentelemetry.io") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); - attributes = removeAttribute(this.attributes, SemanticAttributes.SERVER_ADDRESS); + attributes = removeAttribute(this.attributes, SemanticAttributes.NET_HOST_NAME); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -383,13 +383,13 @@ void hostNotMatch() { void pathMatches() { Attributes attributes = this.attributes.toBuilder() - .put(SemanticAttributes.URL_PATH, "/instrument-me?foo=bar&cat=") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-me?foo=bar&cat=") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); // Deceptive question mark, it's actually a wildcard :-) attributes = this.attributes.toBuilder() - .put(SemanticAttributes.URL_PATH, "/instrument-meafoo=bar&cat=") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-meafoo=bar&cat=") .build(); assertThat(applier.matches(attributes, resource)).isTrue(); } @@ -398,15 +398,15 @@ void pathMatches() { void pathNotMatch() { Attributes attributes = this.attributes.toBuilder() - .put(SemanticAttributes.URL_PATH, "/instrument-mea?foo=bar&cat=") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-mea?foo=bar&cat=") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); attributes = this.attributes.toBuilder() - .put(SemanticAttributes.URL_PATH, "foo/instrument-meafoo=bar&cat=") + .put(SemanticAttributes.HTTP_TARGET, "foo/instrument-meafoo=bar&cat=") .build(); assertThat(applier.matches(attributes, resource)).isFalse(); - attributes = removeAttribute(this.attributes, SemanticAttributes.URL_PATH); + attributes = removeAttribute(this.attributes, SemanticAttributes.HTTP_TARGET); assertThat(applier.matches(attributes, resource)).isFalse(); } @@ -507,9 +507,9 @@ class AwsLambdaTest { private final Attributes attributes = Attributes.builder() - .put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET") - .put(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io") - .put(SemanticAttributes.URL_PATH, "/instrument-me") + .put(SemanticAttributes.HTTP_METHOD, "GET") + .put(SemanticAttributes.NET_HOST_NAME, "opentelemetry.io") + .put(SemanticAttributes.HTTP_TARGET, "/instrument-me") .put(AttributeKey.stringKey("animal"), "cat") .put(AttributeKey.longKey("speed"), 10) .build();