Skip to content

Commit

Permalink
lambda: include xray source attribute on Link from _X_AMZN_TRACE_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Apr 25, 2023
1 parent 4773c71 commit 916376b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 916376b

Please sign in to comment.