Skip to content

Commit

Permalink
Rename Application terminology to Service terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
thpierce committed Apr 28, 2023
1 parent 7b02d7d commit 437c032
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
*
* <p>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 {

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -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))
Expand Down

0 comments on commit 437c032

Please sign in to comment.