Skip to content

Commit 916376b

Browse files
committed
lambda: include xray source attribute on Link from _X_AMZN_TRACE_ID
1 parent 4773c71 commit 916376b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _determine_links() -> Optional[Sequence[Link]]:
190190

191191
span_context = get_current_span(env_context).get_span_context()
192192
if span_context.is_valid:
193-
links = [Link(span_context)]
193+
links = [Link(span_context, {"source": "x-ray-env"})]
194194

195195
return links
196196

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,14 @@ class TestCase:
252252
name="valid_xray_trace",
253253
context={},
254254
expected_link_trace_id=MOCK_XRAY_TRACE_ID,
255+
expected_link_attributes={"source": "x-ray-env"},
255256
xray_traceid=MOCK_XRAY_TRACE_CONTEXT_SAMPLED,
256257
),
257258
TestCase(
258259
name="invalid_xray_trace",
259260
context={},
260261
expected_link_trace_id=None,
262+
expected_link_attributes={},
261263
xray_traceid=f"0",
262264
),
263265
]
@@ -287,6 +289,9 @@ class TestCase:
287289
self.assertEqual(
288290
link.context.trace_id, test.expected_link_trace_id
289291
)
292+
self.assertEqual(
293+
link.attributes, test.expected_link_attributes
294+
)
290295

291296
self.memory_exporter.clear()
292297
AwsLambdaInstrumentor().uninstrument()

0 commit comments

Comments
 (0)