From 67312a29a811921a95c970c63c20f2967a1a0afe Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Mon, 13 May 2024 13:30:01 -0400 Subject: [PATCH] update system tests to match spec --- tests/parametric/test_headers_tracecontext.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/parametric/test_headers_tracecontext.py b/tests/parametric/test_headers_tracecontext.py index c8013178f63..f380888c2eb 100644 --- a/tests/parametric/test_headers_tracecontext.py +++ b/tests/parametric/test_headers_tracecontext.py @@ -842,7 +842,7 @@ def test_tracestate_w3c_p_extract_datadog_first(self, test_agent, test_library): http_headers=[ ["traceparent", "00-1111111111111111000000000000000-000000003ade68b1-01"], ["tracestate", "dd=s:2;p:0123456789abcdef,foo=1"], - ["x-datadog-parent-id", "9876543210"], + ["x-datadog-parent-id", "123456789"], ["x-datadog-trace-id", "2"], ["x-datadog-tags", "_dd.p.tid=2222222222222222"], ], @@ -868,7 +868,7 @@ def test_tracestate_w3c_p_extract_datadog_first(self, test_agent, test_library): http_headers=[ ["traceparent", "00-00000000000000000000000000000006-000000003ade68b1-01"], ["tracestate", "dd=s:2,foo=1"], - ["x-datadog-parent-id", "987654321"], + ["x-datadog-parent-id", "123456789"], ["x-datadog-tags", "_dd.p.tid=6"], ], ): @@ -885,26 +885,29 @@ def test_tracestate_w3c_p_extract_datadog_first(self, test_agent, test_library): ) # 1) Datadog and tracecontext headers, trace-id and span-id match - # There is no need to propagate + # There is no need to propagate _dd.parent_id assert case1["name"] == "identical_trace_info" + assert case1["parent_id"] == "987654321" assert "_dd.parent_id" not in case1["meta"] # 2) trace-ids do not match # Datadog and tracecontext headers contain spans from different traces - # We can not reparent the trace + # We can not reparent the trace, datadog headers are used assert case2["name"] == "trace_ids_do_not_match" + assert case2["parent_id"] == "123456789" assert "_dd.parent_id" not in case2["meta"] # 3) Datadog and tracecontext headers, trace-id matches but parent ids do not - # Ensure the `p` value is used from the tracestate header + # Ensure the last parent id tag is set using the datadog header assert case3["name"] == "same_trace_non_matching_parent_ids" - assert case3["meta"]["_dd.parent_id"] == "000000000000000a" + assert case3["parent_id"] == "16" + assert case3["meta"]["_dd.parent_id"] == "000000003ade68b1" # 4) Datadog and tracecontext headers, parent ids do not match and p value is not present in tracestate - # The upstream Datadog tracer did not set `p` in tracestate, so we do not have the information - # to reparent the span. We should set the last datadog parent id to unknown (0000000000000000) + # Ensure the last parent id tag is set using the datadog header assert case4["name"] == "non_matching_span_missing_p_value" - assert case4["meta"]["_dd.parent_id"] == "0000000000000000" + assert case4["parent_id"] == "987654321" + assert case4["meta"]["_dd.parent_id"] == "00000000075bcd15" # W3C Phase 3 to try adding the tag if the span id matches regardless of headers order(if tracecontext is accounted)