Skip to content

Commit 43af1e5

Browse files
committed
populate aws.trace.flag.sampled attribute only if unsampled
1 parent 3557f6a commit 43af1e5

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsUnsampledOnlySpanProcessor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public static AwsUnsampledOnlySpanProcessorBuilder builder() {
4040

4141
@Override
4242
public void onStart(Context parentContext, ReadWriteSpan span) {
43-
if (span.getSpanContext().isSampled()) {
44-
span.setAttribute(AwsAttributeKeys.AWS_TRACE_FLAG_SAMPLED, true);
45-
} else {
43+
if (!span.getSpanContext().isSampled()) {
4644
span.setAttribute(AwsAttributeKeys.AWS_TRACE_FLAG_SAMPLED, false);
4745
}
4846
delegate.onStart(parentContext, span);

awsagentprovider/src/test/java/software/amazon/opentelemetry/javaagent/providers/AwsUnsampledOnlySpanProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public void testStartAddsAttributeToSampledSpan() {
8888
AwsUnsampledOnlySpanProcessor processor = AwsUnsampledOnlySpanProcessor.builder().build();
8989
processor.onStart(parentContextMock, spanMock);
9090

91-
// verify setAttribute was called with the correct arguments
92-
verify(spanMock, times(1)).setAttribute(AwsAttributeKeys.AWS_TRACE_FLAG_SAMPLED, true);
91+
// verify setAttribute was never called
92+
verify(spanMock, never()).setAttribute(any(), anyBoolean());
9393
}
9494

9595
@Test

0 commit comments

Comments
 (0)