From 3d2f68c8ed875574ec2a17e82aa283f1f721926b Mon Sep 17 00:00:00 2001 From: Mengyi Zhou Date: Thu, 7 Dec 2023 14:05:06 -0800 Subject: [PATCH] replace deprecated semantic attributes --- .../AwsMetricAttributeGenerator.java | 42 +++++------ .../providers/AwsSpanMetricsProcessor.java | 6 +- .../providers/AwsSpanProcessingUtil.java | 16 ++-- .../AwsMetricAttributeGeneratorTest.java | 74 +++++++++---------- .../AwsSpanMetricsProcessorTest.java | 20 ++--- .../providers/AwsSpanProcessingUtilTest.java | 14 ++-- 6 files changed, 86 insertions(+), 86 deletions(-) diff --git a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java index 4229f33f59..f1312dbeaa 100644 --- a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java +++ b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGenerator.java @@ -21,18 +21,18 @@ 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_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_URL; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_METHOD; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_OPERATION; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_SYSTEM; -import static io.opentelemetry.semconv.SemanticAttributes.NET_PEER_NAME; -import static io.opentelemetry.semconv.SemanticAttributes.NET_PEER_PORT; -import static io.opentelemetry.semconv.SemanticAttributes.NET_SOCK_PEER_ADDR; -import static io.opentelemetry.semconv.SemanticAttributes.NET_SOCK_PEER_PORT; 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 software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_BUCKET_NAME; import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_OPERATION; import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_SERVICE; @@ -288,8 +288,8 @@ private static void setRemoteServiceAndOperation(SpanData span, AttributesBuilde */ private static String generateRemoteOperation(SpanData span) { String remoteOperation = UNKNOWN_REMOTE_OPERATION; - if (isKeyPresent(span, HTTP_URL)) { - String httpUrl = span.getAttributes().get(HTTP_URL); + if (isKeyPresent(span, URL_FULL)) { + String httpUrl = span.getAttributes().get(URL_FULL); try { URL url; if (httpUrl != null) { @@ -300,8 +300,8 @@ private static String generateRemoteOperation(SpanData span) { logger.log(Level.FINEST, "invalid http.url attribute: ", httpUrl); } } - if (isKeyPresent(span, HTTP_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_METHOD); + if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); remoteOperation = httpMethod + " " + remoteOperation; } if (remoteOperation.equals(UNKNOWN_REMOTE_OPERATION)) { @@ -312,16 +312,16 @@ private static String generateRemoteOperation(SpanData span) { private static String generateRemoteService(SpanData span) { String remoteService = UNKNOWN_REMOTE_SERVICE; - 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); + if (isKeyPresent(span, SERVER_ADDRESS)) { + remoteService = getRemoteService(span, SERVER_ADDRESS); + if (isKeyPresent(span, SERVER_PORT)) { + Long port = span.getAttributes().get(SERVER_PORT); remoteService += ":" + 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); + } 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); remoteService += ":" + port; } } else { @@ -349,13 +349,13 @@ private static void setSpanKindForDependency(SpanData span, AttributesBuilder bu * allow for desired metric creation. */ private static void setHttpStatus(SpanData span, AttributesBuilder builder) { - if (isKeyPresent(span, HTTP_STATUS_CODE)) { + if (isKeyPresent(span, HTTP_RESPONSE_STATUS_CODE)) { return; } Long statusCode = getAwsStatusCode(span); if (statusCode != null) { - builder.put(HTTP_STATUS_CODE, statusCode); + builder.put(HTTP_RESPONSE_STATUS_CODE, statusCode); } } diff --git a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessor.java b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessor.java index 371f28ee01..46a045db20 100644 --- a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessor.java +++ b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessor.java @@ -15,7 +15,7 @@ package software.amazon.opentelemetry.javaagent.providers; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.metrics.DoubleHistogram; @@ -118,11 +118,11 @@ public boolean isEndRequired() { // possible except for the throttle // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/awsxrayexporter/internal/translator/cause.go#L121-L160 private void recordErrorOrFault(SpanData spanData, Attributes attributes) { - Long httpStatusCode = spanData.getAttributes().get(HTTP_STATUS_CODE); + Long httpStatusCode = spanData.getAttributes().get(HTTP_RESPONSE_STATUS_CODE); StatusCode statusCode = spanData.getStatus().getStatusCode(); if (httpStatusCode == null) { - httpStatusCode = attributes.get(HTTP_STATUS_CODE); + httpStatusCode = attributes.get(HTTP_RESPONSE_STATUS_CODE); } if (httpStatusCode == null diff --git a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtil.java b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtil.java index 119e3fc772..327a913693 100644 --- a/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtil.java +++ b/awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtil.java @@ -15,11 +15,11 @@ package software.amazon.opentelemetry.javaagent.providers; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_METHOD; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_TARGET; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_REQUEST_METHOD; import static io.opentelemetry.semconv.SemanticAttributes.MESSAGING_OPERATION; import static io.opentelemetry.semconv.SemanticAttributes.MessagingOperationValues.PROCESS; import static io.opentelemetry.semconv.SemanticAttributes.RPC_SYSTEM; +import static io.opentelemetry.semconv.SemanticAttributes.URL_PATH; import static software.amazon.opentelemetry.javaagent.providers.AwsAttributeKeys.AWS_LOCAL_OPERATION; import io.opentelemetry.api.common.AttributeKey; @@ -156,8 +156,8 @@ private static boolean isValidOperation(SpanData span, String operation) { if (operation == null || operation.equals(UNKNOWN_OPERATION)) { return false; } - if (isKeyPresent(span, HTTP_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_METHOD); + if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); return !operation.equals(httpMethod); } return true; @@ -169,15 +169,15 @@ private static boolean isValidOperation(SpanData span, String operation) { */ private static String generateIngressOperation(SpanData span) { String operation = UNKNOWN_OPERATION; - if (isKeyPresent(span, HTTP_TARGET)) { - String httpTarget = span.getAttributes().get(HTTP_TARGET); + if (isKeyPresent(span, URL_PATH)) { + String httpTarget = span.getAttributes().get(URL_PATH); // 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_METHOD)) { - String httpMethod = span.getAttributes().get(HTTP_METHOD); + if (isKeyPresent(span, HTTP_REQUEST_METHOD)) { + String httpMethod = span.getAttributes().get(HTTP_REQUEST_METHOD); if (httpMethod != null) { operation = httpMethod + " " + operation; } diff --git a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java index d4f7375994..199eda8ebe 100644 --- a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java +++ b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsMetricAttributeGeneratorTest.java @@ -361,7 +361,7 @@ public void testServerSpanWithNullSpanName() { public void testServerSpanWithSpanNameAsHttpMethod() { updateResourceWithServiceName(); when(spanDataMock.getName()).thenReturn("GET"); - mockAttribute(HTTP_METHOD, "GET"); + mockAttribute(HTTP_REQUEST_METHOD, "GET"); Attributes expectedAttributes = Attributes.of( @@ -369,15 +369,15 @@ public void testServerSpanWithSpanNameAsHttpMethod() { AWS_LOCAL_SERVICE, SERVICE_NAME_VALUE, AWS_LOCAL_OPERATION, UNKNOWN_OPERATION); validateAttributesProducedForNonLocalRootSpanOfKind(expectedAttributes, SpanKind.SERVER); - mockAttribute(HTTP_METHOD, null); + mockAttribute(HTTP_REQUEST_METHOD, null); } @Test public void testServerSpanWithSpanNameWithHttpTarget() { updateResourceWithServiceName(); when(spanDataMock.getName()).thenReturn("POST"); - mockAttribute(HTTP_METHOD, "POST"); - mockAttribute(HTTP_TARGET, "/payment/123"); + mockAttribute(HTTP_REQUEST_METHOD, "POST"); + mockAttribute(URL_PATH, "/payment/123"); Attributes expectedAttributes = Attributes.of( @@ -388,8 +388,8 @@ public void testServerSpanWithSpanNameWithHttpTarget() { AWS_LOCAL_OPERATION, "POST /payment"); validateAttributesProducedForNonLocalRootSpanOfKind(expectedAttributes, SpanKind.SERVER); - mockAttribute(HTTP_METHOD, null); - mockAttribute(HTTP_TARGET, null); + mockAttribute(HTTP_REQUEST_METHOD, null); + mockAttribute(URL_PATH, null); } @Test @@ -473,45 +473,45 @@ public void testRemoteAttributesCombinations() { validateExpectedRemoteAttributes("graphql", "GraphQL operation type"); mockAttribute(GRAPHQL_OPERATION_TYPE, null); - // Validate behaviour of extracting Remote Service from net.peer.name - mockAttribute(NET_PEER_NAME, "www.example.com"); + // Validate behaviour of extracting Remote Service from server.address + mockAttribute(SERVER_ADDRESS, "www.example.com"); validateExpectedRemoteAttributes("www.example.com", UNKNOWN_REMOTE_OPERATION); - mockAttribute(NET_PEER_NAME, null); + mockAttribute(SERVER_ADDRESS, null); - // Validate behaviour of extracting Remote Service from net.peer.name and net.peer.port - mockAttribute(NET_PEER_NAME, "192.168.0.0"); - mockAttribute(NET_PEER_PORT, 8081L); + // Validate behaviour of extracting Remote Service from server.address and server.port + mockAttribute(SERVER_ADDRESS, "192.168.0.0"); + mockAttribute(SERVER_PORT, 8081L); validateExpectedRemoteAttributes("192.168.0.0:8081", UNKNOWN_REMOTE_OPERATION); - mockAttribute(NET_PEER_NAME, null); - mockAttribute(NET_PEER_PORT, null); + mockAttribute(SERVER_ADDRESS, null); + mockAttribute(SERVER_PORT, null); - // Validate behaviour of extracting Remote Service from net.peer.socket.addr - mockAttribute(NET_SOCK_PEER_ADDR, "www.example.com"); + // Validate behaviour of extracting Remote Service from server.socket.address + mockAttribute(SERVER_SOCKET_ADDRESS, "www.example.com"); validateExpectedRemoteAttributes("www.example.com", UNKNOWN_REMOTE_OPERATION); - mockAttribute(NET_SOCK_PEER_ADDR, null); + mockAttribute(SERVER_SOCKET_ADDRESS, null); - // Validate behaviour of extracting Remote Service from net.peer.socket.addr and - // net.sock.peer.port - mockAttribute(NET_SOCK_PEER_ADDR, "192.168.0.0"); - mockAttribute(NET_SOCK_PEER_PORT, 8081L); + // Validate behaviour of extracting Remote Service from server.socket.address and + // server.socket.port + mockAttribute(SERVER_SOCKET_ADDRESS, "192.168.0.0"); + mockAttribute(SERVER_SOCKET_PORT, 8081L); validateExpectedRemoteAttributes("192.168.0.0:8081", UNKNOWN_REMOTE_OPERATION); - mockAttribute(NET_SOCK_PEER_ADDR, null); - mockAttribute(NET_SOCK_PEER_PORT, null); + mockAttribute(SERVER_SOCKET_ADDRESS, null); + mockAttribute(SERVER_SOCKET_PORT, null); - // Validate behavior of Remote Operation from HttpTarget - with 1st api part, then remove it - mockAttribute(HTTP_URL, "http://www.example.com/payment/123"); + // Validate behavior of Remote Operation from url - with 1st api part, then remove it + mockAttribute(URL_FULL, "http://www.example.com/payment/123"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, "/payment"); - mockAttribute(HTTP_URL, null); + mockAttribute(URL_FULL, null); - // Validate behavior of Remote Operation from HttpTarget - without 1st api part, then remove it - mockAttribute(HTTP_URL, "http://www.example.com"); + // Validate behavior of Remote Operation from url - without 1st api part, then remove it + mockAttribute(URL_FULL, "http://www.example.com"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, "/"); - mockAttribute(HTTP_URL, null); + mockAttribute(URL_FULL, null); - // Validate behavior of Remote Operation from HttpTarget - invalid url, then remove it - mockAttribute(HTTP_URL, "abc"); + // Validate behavior of Remote Operation from url - invalid url, then remove it + mockAttribute(URL_FULL, "abc"); validateExpectedRemoteAttributes(UNKNOWN_REMOTE_SERVICE, UNKNOWN_REMOTE_OPERATION); - mockAttribute(HTTP_URL, null); + mockAttribute(URL_FULL, null); // Validate behaviour of Peer service attribute, then remove it. mockAttribute(PEER_SERVICE, "Peer service"); @@ -529,8 +529,8 @@ public void testPeerServiceDoesOverrideOtherRemoteServices() { validatePeerServiceDoesOverride(FAAS_INVOKED_PROVIDER); validatePeerServiceDoesOverride(MESSAGING_SYSTEM); validatePeerServiceDoesOverride(GRAPHQL_OPERATION_TYPE); - validatePeerServiceDoesOverride(NET_PEER_NAME); - validatePeerServiceDoesOverride(NET_SOCK_PEER_ADDR); + validatePeerServiceDoesOverride(SERVER_ADDRESS); + validatePeerServiceDoesOverride(SERVER_SOCKET_ADDRESS); // Actually testing that peer service overrides "UnknownRemoteService". validatePeerServiceDoesOverride(AttributeKey.stringKey("unknown.service.key")); } @@ -577,7 +577,7 @@ public void testHttpStatusAttributeNotAwsSdk() { @Test public void testHttpStatusAttributeStatusAlreadyPresent() { when(instrumentationScopeInfoMock.getName()).thenReturn("aws-sdk"); - mockAttribute(HTTP_STATUS_CODE, 200L); + mockAttribute(HTTP_RESPONSE_STATUS_CODE, 200L); validateHttpStatusWithThrowable(new ThrowableWithMethodGetStatusCode(500), null); } @@ -733,9 +733,9 @@ private void validateHttpStatusForNonLocalRootWithThrowableForClient( actualAttributes = attributeMap.get(SERVICE_METRIC); } } - assertThat(actualAttributes.get(HTTP_STATUS_CODE)).isEqualTo(expectedStatusCode); + assertThat(actualAttributes.get(HTTP_RESPONSE_STATUS_CODE)).isEqualTo(expectedStatusCode); if (expectedStatusCode == null) { - assertThat(actualAttributes.asMap().containsKey(HTTP_STATUS_CODE)).isFalse(); + assertThat(actualAttributes.asMap().containsKey(HTTP_RESPONSE_STATUS_CODE)).isFalse(); } } diff --git a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessorTest.java b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessorTest.java index bd16f81673..7a362025a2 100644 --- a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessorTest.java +++ b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanMetricsProcessorTest.java @@ -15,7 +15,7 @@ package software.amazon.opentelemetry.javaagent.providers; -import static io.opentelemetry.semconv.SemanticAttributes.HTTP_STATUS_CODE; +import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -134,7 +134,7 @@ public void testOnEndMetricsGenerationWithoutSpanAttributes() { @Test public void testOnEndMetricsGenerationWithoutMetricAttributes() { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 500L); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 500L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Map metricAttributesMap = buildMetricAttributes(CONTAINS_NO_ATTRIBUTES, readableSpanMock.toSpanData()); @@ -266,7 +266,7 @@ public void testsOnEndMetricsGenerationProducerSpan() { @Test public void testOnEndMetricsGenerationWithoutEndRequired() { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 500L); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 500L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Map metricAttributesMap = buildMetricAttributes(CONTAINS_ATTRIBUTES, readableSpanMock.toSpanData()); @@ -289,7 +289,7 @@ public void testOnEndMetricsGenerationWithoutEndRequired() { @Test public void testOnEndMetricsGenerationWithLatency() { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, 200L); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, 200L); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes); Map metricAttributesMap = buildMetricAttributes(CONTAINS_ATTRIBUTES, readableSpanMock.toSpanData()); @@ -433,7 +433,7 @@ private static ReadableSpan buildReadableSpanMock( private static ReadableSpan buildReadableSpanWithThrowableMock(Throwable throwable) { // config http status code as null - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, null); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, null); ReadableSpan readableSpanMock = mock(ReadableSpan.class); SpanData mockSpanData = mock(SpanData.class); InstrumentationScopeInfo awsSdkScopeInfo = @@ -469,7 +469,7 @@ private void configureMocksForOnEnd( private void validateMetricsGeneratedForHttpStatusCode( Long httpStatusCode, ExpectedStatusMetric expectedStatusMetric) { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, httpStatusCode); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, httpStatusCode); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes, SpanKind.PRODUCER, null, StatusData.unset()); Map metricAttributesMap = @@ -494,14 +494,14 @@ private void validateMetricsGeneratedForAttributeStatusCode( Attributes.of( AttributeKey.stringKey("new service key"), "new service value", - HTTP_STATUS_CODE, + HTTP_RESPONSE_STATUS_CODE, awsStatusCode)); metricAttributesMap.put( DEPENDENCY_METRIC, Attributes.of( AttributeKey.stringKey("new dependency key"), "new dependency value", - HTTP_STATUS_CODE, + HTTP_RESPONSE_STATUS_CODE, awsStatusCode)); } configureMocksForOnEnd(readableSpanMock, metricAttributesMap); @@ -511,7 +511,7 @@ private void validateMetricsGeneratedForAttributeStatusCode( private void validateMetricsGeneratedForStatusDataError( Long httpStatusCode, ExpectedStatusMetric expectedStatusMetric) { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, httpStatusCode); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, httpStatusCode); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes, SpanKind.PRODUCER, null, StatusData.error()); Map metricAttributesMap = @@ -524,7 +524,7 @@ private void validateMetricsGeneratedForStatusDataError( private void validateMetricsGeneratedForStatusDataOk( Long httpStatusCode, ExpectedStatusMetric expectedStatusMetric) { - Attributes spanAttributes = Attributes.of(HTTP_STATUS_CODE, httpStatusCode); + Attributes spanAttributes = Attributes.of(HTTP_RESPONSE_STATUS_CODE, httpStatusCode); ReadableSpan readableSpanMock = buildReadableSpanMock(spanAttributes, SpanKind.PRODUCER, null, StatusData.ok()); diff --git a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtilTest.java b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtilTest.java index 4f319aa6d0..97bf619c88 100644 --- a/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtilTest.java +++ b/awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsSpanProcessingUtilTest.java @@ -70,7 +70,7 @@ public void testGetIngressOperationHttpMethodNameAndNoFallback() { String invalidName = "GET"; when(spanDataMock.getName()).thenReturn(invalidName); when(spanDataMock.getKind()).thenReturn(SpanKind.SERVER); - when(attributesMock.get(HTTP_METHOD)).thenReturn(invalidName); + when(attributesMock.get(HTTP_REQUEST_METHOD)).thenReturn(invalidName); String actualOperation = AwsSpanProcessingUtil.getIngressOperation(spanDataMock); assertThat(actualOperation).isEqualTo(UNKNOWN_OPERATION); } @@ -99,7 +99,7 @@ public void testGetIngressOperationInvalidNameAndValidTarget() { String validTarget = "/"; when(spanDataMock.getName()).thenReturn(invalidName); when(spanDataMock.getKind()).thenReturn(SpanKind.SERVER); - when(attributesMock.get(HTTP_TARGET)).thenReturn(validTarget); + when(attributesMock.get(URL_PATH)).thenReturn(validTarget); String actualOperation = AwsSpanProcessingUtil.getIngressOperation(spanDataMock); assertThat(actualOperation).isEqualTo(validTarget); } @@ -111,8 +111,8 @@ public void testGetIngressOperationInvalidNameAndValidTargetAndMethod() { String validMethod = "GET"; when(spanDataMock.getName()).thenReturn(invalidName); when(spanDataMock.getKind()).thenReturn(SpanKind.SERVER); - when(attributesMock.get(HTTP_TARGET)).thenReturn(validTarget); - when(attributesMock.get(HTTP_METHOD)).thenReturn(validMethod); + when(attributesMock.get(URL_PATH)).thenReturn(validTarget); + when(attributesMock.get(HTTP_REQUEST_METHOD)).thenReturn(validMethod); String actualOperation = AwsSpanProcessingUtil.getIngressOperation(spanDataMock); assertThat(actualOperation).isEqualTo(validMethod + " " + validTarget); } @@ -180,13 +180,13 @@ public void testExtractAPIPathValidPath() { @Test public void testIsKeyPresentKeyPresent() { - when(attributesMock.get(HTTP_TARGET)).thenReturn("target"); - assertThat(AwsSpanProcessingUtil.isKeyPresent(spanDataMock, HTTP_TARGET)).isTrue(); + when(attributesMock.get(URL_PATH)).thenReturn("target"); + assertThat(AwsSpanProcessingUtil.isKeyPresent(spanDataMock, URL_PATH)).isTrue(); } @Test public void testIsKeyPresentKeyAbsent() { - assertThat(AwsSpanProcessingUtil.isKeyPresent(spanDataMock, HTTP_TARGET)).isFalse(); + assertThat(AwsSpanProcessingUtil.isKeyPresent(spanDataMock, URL_PATH)).isFalse(); } @Test