Skip to content

Commit

Permalink
Update test to show Active Tracing span is ignored by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbenson committed Mar 29, 2024
1 parent 18846c6 commit 7d56c0c
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.trace.data.StatusData;
Expand Down Expand Up @@ -91,11 +89,15 @@ void handlerTracedWithException() {
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}

/**
* For more details about active tracing see
* https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html
*/
@Test
@SetEnvironmentVariable(
key = "_X_AMZN_TRACE_ID",
value = "Root=1-8a3c60f7-d188f8fa79d48a391a778fa6;Parent=0000000000000456;Sampled=1")
void handlerLinksToInfrastructureTrace() {
void handlerDoesNotLinkToActiveTracingSpan() {
String result = handler().handleRequest("hello", context);
assertThat(result).isEqualTo("world");

Expand All @@ -106,22 +108,8 @@ void handlerLinksToInfrastructureTrace() {
span ->
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasLinksSatisfying(
links ->
assertThat(links)
.singleElement()
.satisfies(
link -> {
assertThat(link.getSpanContext().getTraceId())
.isEqualTo("8a3c60f7d188f8fa79d48a391a778fa6");
assertThat(link.getSpanContext().getSpanId())
.isEqualTo("0000000000000456");
assertThat(link.getAttributes())
.isEqualTo(
Attributes.of(
AttributeKey.stringKey("source"),
"x-ray-env"));
}))
.hasNoParent()
.hasLinks()
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
Expand Down

0 comments on commit 7d56c0c

Please sign in to comment.