diff --git a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessor.java b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessor.java index 5a867b2c6..598b64623 100644 --- a/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessor.java +++ b/aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessor.java @@ -16,14 +16,14 @@ /** * AwsAttributePropagatingSpanProcessor handles the creation of the aws.local.operation attribute, * and the inheritance of the {@link AwsAttributeKeys#AWS_LOCAL_OPERATION}, {@link - * AwsAttributeKeys#AWS_REMOTE_APPLICATION} and {@link AwsAttributeKeys#AWS_REMOTE_OPERATION}. + * AwsAttributeKeys#AWS_REMOTE_SERVICE} and {@link AwsAttributeKeys#AWS_REMOTE_OPERATION}. * *

The {@link AwsAttributeKeys#AWS_LOCAL_OPERATION} is created when a local root span of SERVER * or CONSUMER type is found. The span name will be used as the attribute value. The {@link - * AwsAttributeKeys#AWS_REMOTE_APPLICATION} and {@link AwsAttributeKeys#AWS_REMOTE_OPERATION} - * attributes must be created by manual instrumentation. These attributes will be copied from the - * parent span to children after receiving them, and later be used in SpanMetricsProcessor to help - * generate metric attributes. + * AwsAttributeKeys#AWS_REMOTE_SERVICE} and {@link AwsAttributeKeys#AWS_REMOTE_OPERATION} attributes + * must be created by manual instrumentation. These attributes will be copied from the parent span + * to children after receiving them, and later be used in SpanMetricsProcessor to help generate + * metric attributes. */ public final class AwsAttributePropagatingSpanProcessor implements SpanProcessor { @@ -52,10 +52,9 @@ && isServerOrConsumer(parentReadableSpan)) { span.setAttribute(AwsAttributeKeys.AWS_LOCAL_OPERATION, localOperation); } - String remoteApplication = - parentReadableSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION); - if (remoteApplication != null) { - span.setAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION, remoteApplication); + String remoteService = parentReadableSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE); + if (remoteService != null) { + span.setAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE, remoteService); } String remoteOperation = parentReadableSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_OPERATION); diff --git a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessorTest.java b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessorTest.java index 86a7316e1..3de7c63e3 100644 --- a/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessorTest.java +++ b/aws-xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsAttributePropagatingSpanProcessorTest.java @@ -34,23 +34,23 @@ public void setup() { @Test public void testRemoteAttributesInheritance() { Span spanWithAppOnly = tracer.spanBuilder("parent").startSpan(); - spanWithAppOnly.setAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION, "testApplication"); - validateSpanAttributesInheritance(spanWithAppOnly, null, "testApplication", null); + spanWithAppOnly.setAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE, "testService"); + validateSpanAttributesInheritance(spanWithAppOnly, null, "testService", null); Span spanWithOpOnly = tracer.spanBuilder("parent").startSpan(); spanWithOpOnly.setAttribute(AwsAttributeKeys.AWS_REMOTE_OPERATION, "testOperation"); validateSpanAttributesInheritance(spanWithOpOnly, null, null, "testOperation"); Span spanWithAppAndOp = tracer.spanBuilder("parent").startSpan(); - spanWithAppAndOp.setAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION, "testApplication"); + spanWithAppAndOp.setAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE, "testService"); spanWithAppAndOp.setAttribute(AwsAttributeKeys.AWS_REMOTE_OPERATION, "testOperation"); - validateSpanAttributesInheritance(spanWithAppAndOp, null, "testApplication", "testOperation"); + validateSpanAttributesInheritance(spanWithAppAndOp, null, "testService", "testOperation"); } @Test public void testOverrideRemoteAttributes() { Span parentSpan = tracer.spanBuilder("parent").startSpan(); - parentSpan.setAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION, "testApplication"); + parentSpan.setAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE, "testService"); parentSpan.setAttribute(AwsAttributeKeys.AWS_REMOTE_OPERATION, "testOperation"); Span transmitSpans1 = createNestedSpan(parentSpan, 2); @@ -120,11 +120,8 @@ private Span createNestedSpan(Span parentSpan, int depth) { } private void validateSpanAttributesInheritance( - Span spanWithAppOnly, - String localOperation, - String remoteApplication, - String remoteOperation) { - ReadableSpan leafSpan = (ReadableSpan) createNestedSpan(spanWithAppOnly, 10); + Span parentSpan, String localOperation, String remoteService, String remoteOperation) { + ReadableSpan leafSpan = (ReadableSpan) createNestedSpan(parentSpan, 10); assertThat(leafSpan.getParentSpanContext()).isNotNull(); assertThat(leafSpan.getName()).isEqualTo("child:1"); @@ -134,11 +131,11 @@ private void validateSpanAttributesInheritance( } else { assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_LOCAL_OPERATION)).isNull(); } - if (remoteApplication != null) { - assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION)) - .isEqualTo(remoteApplication); + if (remoteService != null) { + assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE)) + .isEqualTo(remoteService); } else { - assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_APPLICATION)).isNull(); + assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_SERVICE)).isNull(); } if (remoteOperation != null) { assertThat(leafSpan.getAttribute(AwsAttributeKeys.AWS_REMOTE_OPERATION))