Skip to content

Commit

Permalink
wIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jun 10, 2024
1 parent f9f62e4 commit f0fcb28
Showing 1 changed file with 16 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,48 +40,6 @@
AwsXrayLambdaPropagator
)

set_trace

TRACE_ID_BASE16 = "8a3c60f7d188f8fa79d48a391a778fa6"

SPAN_ID_BASE16 = "53995c3f42cd8ad8"


def build_test_span_context(
trace_id=int(TRACE_ID_BASE16, 16),
span_id=int(SPAN_ID_BASE16, 16),
is_remote=True,
trace_flags=DEFAULT_TRACE_OPTIONS,
trace_state=DEFAULT_TRACE_STATE,
):
return SpanContext(
trace_id,
span_id,
is_remote,
trace_flags,
trace_state,
)


def get_nested_span_context(parent_context):
return get_current_span(parent_context).get_span_context()


def build_test_current_context(
trace_id=int(TRACE_ID_BASE16, 16),
span_id=int(SPAN_ID_BASE16, 16),
is_remote=True,
trace_flags=DEFAULT_TRACE_OPTIONS,
trace_state=DEFAULT_TRACE_STATE,
):
return set_span_in_context(
NonRecordingSpan(
build_test_span_context(
trace_id, span_id, is_remote, trace_flags, trace_state
)
)
)


class AwsXRayLambdaPropagatorTest(TestCase):

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

default_getter = DefaultGetter()

actual = get_nested_span_context(
actual_context = get_current_span(
propagator.extract(
{},
context=get_current(),
getter=default_getter
)
)
).get_span_context()

expected = build_test_span_context(
trace_id=int("00000001d188f8fa79d48a391a778fa6", 16),
trace_flags=TraceFlags(TraceFlags.SAMPLED)
self.assertEqual(
hex(actual_context.trace_id),
"0x1d188f8fa79d48a391a778fa6"
)
self.assertEqual(
hex(actual_context.span_id),
"0x53995c3f42cd8ad8"
)
self.assertTrue(
actual_context.trace_flags.sampled,
)
self.assertEqual(
actual,
expected
actual_context.trace_state,
TraceState.get_default()
)

@patch.dict(
Expand All @@ -128,6 +93,8 @@ def test_extract_from_environment_variable(self):
}
)
def test_add_link_from_environment_variable(self):
# TODO fix this test case

propagator = AwsXrayLambdaPropagator()

default_getter = DefaultGetter()
Expand Down

0 comments on commit f0fcb28

Please sign in to comment.