40
40
AwsXrayLambdaPropagator
41
41
)
42
42
43
- set_trace
44
-
45
- TRACE_ID_BASE16 = "8a3c60f7d188f8fa79d48a391a778fa6"
46
-
47
- SPAN_ID_BASE16 = "53995c3f42cd8ad8"
48
-
49
-
50
- def build_test_span_context (
51
- trace_id = int (TRACE_ID_BASE16 , 16 ),
52
- span_id = int (SPAN_ID_BASE16 , 16 ),
53
- is_remote = True ,
54
- trace_flags = DEFAULT_TRACE_OPTIONS ,
55
- trace_state = DEFAULT_TRACE_STATE ,
56
- ):
57
- return SpanContext (
58
- trace_id ,
59
- span_id ,
60
- is_remote ,
61
- trace_flags ,
62
- trace_state ,
63
- )
64
-
65
-
66
- def get_nested_span_context (parent_context ):
67
- return get_current_span (parent_context ).get_span_context ()
68
-
69
-
70
- def build_test_current_context (
71
- trace_id = int (TRACE_ID_BASE16 , 16 ),
72
- span_id = int (SPAN_ID_BASE16 , 16 ),
73
- is_remote = True ,
74
- trace_flags = DEFAULT_TRACE_OPTIONS ,
75
- trace_state = DEFAULT_TRACE_STATE ,
76
- ):
77
- return set_span_in_context (
78
- NonRecordingSpan (
79
- build_test_span_context (
80
- trace_id , span_id , is_remote , trace_flags , trace_state
81
- )
82
- )
83
- )
84
-
85
43
86
44
class AwsXRayLambdaPropagatorTest (TestCase ):
87
45
@@ -100,21 +58,28 @@ def test_extract_from_environment_variable(self):
100
58
101
59
default_getter = DefaultGetter ()
102
60
103
- actual = get_nested_span_context (
61
+ actual_context = get_current_span (
104
62
propagator .extract (
105
63
{},
106
64
context = get_current (),
107
65
getter = default_getter
108
66
)
109
- )
67
+ ). get_span_context ()
110
68
111
- expected = build_test_span_context (
112
- trace_id = int ("00000001d188f8fa79d48a391a778fa6" , 16 ),
113
- trace_flags = TraceFlags (TraceFlags .SAMPLED )
69
+ self .assertEqual (
70
+ hex (actual_context .trace_id ),
71
+ "0x1d188f8fa79d48a391a778fa6"
72
+ )
73
+ self .assertEqual (
74
+ hex (actual_context .span_id ),
75
+ "0x53995c3f42cd8ad8"
76
+ )
77
+ self .assertTrue (
78
+ actual_context .trace_flags .sampled ,
114
79
)
115
80
self .assertEqual (
116
- actual ,
117
- expected
81
+ actual_context . trace_state ,
82
+ TraceState . get_default ()
118
83
)
119
84
120
85
@patch .dict (
@@ -128,6 +93,8 @@ def test_extract_from_environment_variable(self):
128
93
}
129
94
)
130
95
def test_add_link_from_environment_variable (self ):
96
+ # TODO fix this test case
97
+
131
98
propagator = AwsXrayLambdaPropagator ()
132
99
133
100
default_getter = DefaultGetter ()
0 commit comments