Skip to content

Commit

Permalink
update system tests to match spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed May 13, 2024
1 parent bf51452 commit 67312a2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/parametric/test_headers_tracecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
],
Expand All @@ -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"],
],
):
Expand All @@ -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)
Expand Down

0 comments on commit 67312a2

Please sign in to comment.