Skip to content

Commit f0fcb28

Browse files
committed
wIP
1 parent f9f62e4 commit f0fcb28

File tree

1 file changed

+16
-49
lines changed

1 file changed

+16
-49
lines changed

Diff for: propagator/opentelemetry-propagator-aws-xray/tests/test_aws_xray_lambda_propagator.py

+16-49
Original file line numberDiff line numberDiff line change
@@ -40,48 +40,6 @@
4040
AwsXrayLambdaPropagator
4141
)
4242

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-
8543

8644
class AwsXRayLambdaPropagatorTest(TestCase):
8745

@@ -100,21 +58,28 @@ def test_extract_from_environment_variable(self):
10058

10159
default_getter = DefaultGetter()
10260

103-
actual = get_nested_span_context(
61+
actual_context = get_current_span(
10462
propagator.extract(
10563
{},
10664
context=get_current(),
10765
getter=default_getter
10866
)
109-
)
67+
).get_span_context()
11068

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,
11479
)
11580
self.assertEqual(
116-
actual,
117-
expected
81+
actual_context.trace_state,
82+
TraceState.get_default()
11883
)
11984

12085
@patch.dict(
@@ -128,6 +93,8 @@ def test_extract_from_environment_variable(self):
12893
}
12994
)
13095
def test_add_link_from_environment_variable(self):
96+
# TODO fix this test case
97+
13198
propagator = AwsXrayLambdaPropagator()
13299

133100
default_getter = DefaultGetter()

0 commit comments

Comments
 (0)