diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py index 4c798748b9..1f4e857ba6 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py @@ -190,7 +190,7 @@ def _determine_links() -> Optional[Sequence[Link]]: span_context = get_current_span(env_context).get_span_context() if span_context.is_valid: - links = [Link(span_context)] + links = [Link(span_context, {"source": "x-ray-env"})] return links diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py index dc40469736..e74ae9b7f9 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py @@ -252,12 +252,14 @@ class TestCase: name="valid_xray_trace", context={}, expected_link_trace_id=MOCK_XRAY_TRACE_ID, + expected_link_attributes={"source": "x-ray-env"}, xray_traceid=MOCK_XRAY_TRACE_CONTEXT_SAMPLED, ), TestCase( name="invalid_xray_trace", context={}, expected_link_trace_id=None, + expected_link_attributes={}, xray_traceid=f"0", ), ] @@ -287,6 +289,9 @@ class TestCase: self.assertEqual( link.context.trace_id, test.expected_link_trace_id ) + self.assertEqual( + link.attributes, test.expected_link_attributes + ) self.memory_exporter.clear() AwsLambdaInstrumentor().uninstrument()