File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ def _convert_xray_sampling(xray_sampled):
89
89
return SamplingPriority .USER_KEEP if xray_sampled else SamplingPriority .USER_REJECT
90
90
91
91
92
- def _get_xray_trace_context () -> Optional [ Context ] :
92
+ def _get_xray_trace_context ():
93
93
if not is_lambda_context ():
94
94
return None
95
95
Original file line number Diff line number Diff line change 14
14
from datadog_lambda .constants import (
15
15
SamplingPriority ,
16
16
TraceHeader ,
17
+ TraceContextSource ,
17
18
XraySubsegment ,
18
19
)
19
20
from datadog_lambda .tracing import (
@@ -854,6 +855,30 @@ def test_mixed_parent_context_when_merging(self):
854
855
self .mock_activate .assert_called ()
855
856
self .mock_activate .assert_has_calls ([call (expected_context )])
856
857
858
+ def test_set_dd_trace_py_root_no_span_id (self ):
859
+ os .environ ["_X_AMZN_TRACE_ID" ] = "Root=1-5e272390-8c398be037738dc042009320"
860
+
861
+ lambda_ctx = get_mock_context ()
862
+ ctx , source , event_type = extract_dd_trace_context (
863
+ {
864
+ "headers" : {
865
+ TraceHeader .TRACE_ID : "123" ,
866
+ TraceHeader .PARENT_ID : "321" ,
867
+ TraceHeader .SAMPLING_PRIORITY : "1" ,
868
+ }
869
+ },
870
+ lambda_ctx ,
871
+ )
872
+ set_dd_trace_py_root (TraceContextSource .EVENT , True )
873
+
874
+ expected_context = Context (
875
+ trace_id = 123 , # Trace Id from incomming context
876
+ span_id = 321 , # Span Id from incoming context
877
+ sampling_priority = 1 , # Sampling priority from incomming context
878
+ )
879
+ self .mock_activate .assert_called ()
880
+ self .mock_activate .assert_has_calls ([call (expected_context )])
881
+
857
882
858
883
class TestAuthorizerInferredSpans (unittest .TestCase ):
859
884
def setUp (self ):
You can’t perform that action at this time.
0 commit comments