Skip to content

Commit

Permalink
parametric: Ensure start span endpoints align with the spec (#3300)
Browse files Browse the repository at this point in the history
Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
  • Loading branch information
mabdinur and bwoebi authored Nov 15, 2024
1 parent 719947a commit 67831f8
Show file tree
Hide file tree
Showing 26 changed files with 526 additions and 464 deletions.
17 changes: 17 additions & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,29 @@ tests/:
Test_Dsm_Manual_Checkpoint_Inter_Process: missing_feature
Test_Dsm_Manual_Checkpoint_Intra_Process: missing_feature
parametric/:
test_128_bit_traceids.py:
Test_128_Bit_Traceids: missing_feature (parametric app does not support trace/span/extract endpoint)
test_config_consistency.py:
Test_Config_RateLimit: v1.1.0
Test_Config_TraceAgentURL: v1.1.0
Test_Config_TraceEnabled: v1.1.0
Test_Config_TraceLogDirectory: missing_feature
Test_Config_UnifiedServiceTagging: v1.1.0
test_crashtracking.py: missing_feature
test_headers_b3multi.py:
Test_Headers_B3multi: missing_feature (parametric app does not support trace/span/extract endpoint)
test_headers_baggage.py:
Test_Headers_Baggage: missing_feature
test_headers_datadog.py:
Test_Headers_Datadog: missing_feature (parametric app does not support trace/span/extract endpoint)
test_headers_none.py:
Test_Headers_None: missing_feature (parametric app does not support trace/span/extract endpoint)
test_headers_precedence.py:
Test_Headers_Precedence: missing_feature (parametric app does not support trace/span/extract endpoint)
test_headers_tracecontext.py:
Test_Headers_Tracecontext: missing_feature (parametric app does not support trace/span/extract endpoint)
test_headers_tracestate_dd.py:
Test_Headers_Tracestate_DD: missing_feature (parametric app does not support trace/span/extract endpoint)
test_otel_api_interoperability.py: irrelevant (library does not implement OpenTelemetry)
test_otel_env_vars.py:
Test_Otel_Env_Vars: missing_feature
Expand All @@ -162,6 +176,7 @@ tests/:
Test_Parametric_DDTrace_Config: missing_feature (config endpoint is not implemented)
Test_Parametric_DDTrace_Crash: missing_feature (crash endpoint is not implemented)
Test_Parametric_DDTrace_Current_Span: missing_feature (current_span endpoint is not implemented)
Test_Parametric_DDTrace_Extract_Headers: missing_feature (extract_headers endpoint is not implemented)
# cpp tracer does not support the OpenTelemetry API, otel parametric endpoints are not implemented
Test_Parametric_OtelSpan_Events: missing_feature (otel api is not supported)
Test_Parametric_OtelSpan_Is_Recording: missing_feature (otel api is not supported)
Expand All @@ -174,6 +189,8 @@ tests/:
Test_Parametric_Otel_Trace_Flush: missing_feature (otel api is not supported)
test_partial_flushing.py:
Test_Partial_Flushing: missing_feature
test_sampling_delegation.py:
Test_Decisionless_Extraction: missing_feature (parametric app does not support trace/span/extract endpoint)
test_span_links.py: missing_feature
test_telemetry.py:
Test_Consistent_Configs: missing_feature
Expand Down
2 changes: 1 addition & 1 deletion manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ tests/:
Test_Otel_Span_With_Baggage: missing_feature
test_parametric_endpoints.py:
Test_Parametric_DDSpan_Set_Resource: missing_feature (set_resource endpoint is not implemented)
Test_Parametric_DDSpan_Start: bug (APMAPI-778) # The service and resource name of the child span is overidden by the parent span.
Test_Parametric_DDSpan_Start: bug (APMAPI-778) # The resource name of the child span is overidden by the parent span.
Test_Parametric_DDTrace_Baggage: missing_feature (baggage endpoints are not implemented)
Test_Parametric_DDTrace_Crash: missing_feature (crash endpoint is not implemented)
Test_Parametric_DDTrace_Current_Span: missing_feature (otel current_span endpoint is not supported)
Expand Down
1 change: 0 additions & 1 deletion manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ tests/:
Test_Otel_Span_With_W3c: v1.17.0
test_parametric_endpoints.py:
Test_Parametric_DDSpan_Set_Resource: missing_feature (set_resource endpoint is not supported)
Test_Parametric_DDSpan_Start: bug (APMAPI-778) # Generating a child span from a finished span is not supported
Test_Parametric_DDTrace_Baggage: missing_feature (baggage is not supported)
Test_Parametric_DDTrace_Current_Span: missing_feature (current span endpoint is not supported)
Test_Parametric_OtelSpan_Set_Name: bug (APMAPI-778) # set_name endpoint should set the resource name on a span (not the operation name)
Expand Down
15 changes: 9 additions & 6 deletions tests/parametric/test_headers_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ def test_baggage_inject_header_D004(self, test_library):

def test_baggage_extract_header_D005(self, test_library):
"""testing baggage header extraction and decoding"""
with test_library.start_span(
name="test_baggage_extract_header_D005",
http_headers=[

with test_library.extract_headers_and_make_child_span(
"test_baggage_extract_header_D005",
[
[
"baggage",
"foo=bar,userId=Am%C3%A9lie,serverNode=DF%2028,%22%2C%3B%5C%28%29%2F%3A%3C%3D%3E%3F%40%5B%5D%7B%7D=%22%2C%3B%5C",
Expand Down Expand Up @@ -141,8 +142,8 @@ def test_baggage_set_disabled_D007(self, test_library):

def test_baggage_get_D008(self, test_library):
"""testing baggage API get_baggage"""
with test_library.start_span(
name="test_baggage_get_D008", http_headers=[["baggage", "userId=Am%C3%A9lie,serverNode=DF%2028"]],
with test_library.extract_headers_and_make_child_span(
"test_baggage_get_D008", [["baggage", "userId=Am%C3%A9lie,serverNode=DF%2028"]]
) as span:
span.set_baggage("foo", "bar")
span.set_baggage("baz", "qux")
Expand All @@ -153,7 +154,9 @@ def test_baggage_get_D008(self, test_library):

def test_baggage_get_all_D009(self, test_library):
"""testing baggage API get_all_baggage"""
with test_library.start_span(name="test_baggage_get_all_D009", http_headers=[["baggage", "foo=bar"]]) as span:
with test_library.extract_headers_and_make_child_span(
"test_baggage_get_all_D009", [["baggage", "foo=bar"]]
) as span:
span.set_baggage("baz", "qux")
span.set_baggage("userId", "Amélie")
span.set_baggage("serverNode", "DF 28")
Expand Down
26 changes: 13 additions & 13 deletions tests/parametric/test_headers_precedence.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts(self,
# 1) Datadog and tracecontext headers, Datadog is primary context,
# trace-id does not match,
# tracestate is present, so should be added to tracecontext span_link
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="span1",
http_headers=[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
Expand All @@ -673,13 +673,13 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts(self,
pass
# 2) Datadog and tracecontext headers, trace-id does match, Datadog is primary context
# we want to make sure there's no span link since they match
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="span2",
http_headers=[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
["tracestate", "dd=s:2;t.tid:1111111111111111,foo=1"],
["x-datadog-trace-id", "1"],
["x-datadog-parent-id", "987654321"],
["x-datadog-parent-id", "987654322"],
["x-datadog-sampling-priority", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
],
Expand All @@ -688,13 +688,13 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts(self,
# 3) Datadog, tracecontext, b3multi headers, Datadog is primary context
# tracecontext and b3multi trace_id do match it
# we should have two span links, b3multi should not have tracestate
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="span3",
http_headers=[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
["tracestate", "dd=s:2;t.tid:1111111111111111,foo=1"],
["x-datadog-trace-id", "4"],
["x-datadog-parent-id", "987654321"],
["x-datadog-parent-id", "987654323"],
["x-datadog-sampling-priority", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
["x-b3-traceid", "11111111111111110000000000000003"],
Expand All @@ -705,26 +705,26 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts(self,
pass
# 4) Datadog, b3multi headers edge case where we want to make sure NOT to create a span_link
# if the secondary context has trace_id 0 since that's not valid.
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="span4",
http_headers=[
["x-datadog-trace-id", "5"],
["x-datadog-parent-id", "987654321"],
["x-datadog-parent-id", "987654324"],
["x-datadog-sampling-priority", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
["x-b3-traceid", "00000000000000000000000000000000"],
["x-b3-spanid", "a2fb4a1d1a96d312"],
["x-b3-spanid", "a2fb4a1d1a96d314"],
["x-b3-sampled", "1"],
],
) as s4:
pass
# 5) Datadog, b3multi headers edge case where we want to make sure NOT to create a span_link
# if the secondary context has span_id 0 since that's not valid.
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="span5",
http_headers=[
["x-datadog-trace-id", "6"],
["x-datadog-parent-id", "987654321"],
["x-datadog-parent-id", "987654325"],
["x-datadog-sampling-priority", "2"],
["x-datadog-tags", "_dd.p.tid=1111111111111111"],
["x-b3-traceid", "11111111111111110000000000000003"],
Expand Down Expand Up @@ -805,7 +805,7 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts_trace
"""
with test_library:
# Trace ids with the three styles do not match
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="trace_ids_do_not_match",
http_headers=[
["traceparent", "00-11111111111111110000000000000002-000000003ade68b1-01"],
Expand Down Expand Up @@ -856,7 +856,7 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts_spanl
"""
with test_library:
# Trace ids with the three styles do not match
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="trace_ids_do_not_match",
http_headers=[
["traceparent", "00-11111111111111110000000000000002-000000003ade68b1-01"],
Expand Down Expand Up @@ -900,7 +900,7 @@ def test_headers_precedence_propagationstyle_resolves_conflicting_contexts_spanl
"""
with test_library:
# Trace ids with the three styles do not match
with test_library.start_span(
with test_library.extract_headers_and_make_child_span(
name="trace_ids_do_not_match",
http_headers=[
["traceparent", "00-11111111111111110000000000000002-000000003ade68b1-01"],
Expand Down
61 changes: 30 additions & 31 deletions tests/parametric/test_headers_tracecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,18 @@ def test_tracestate_w3c_p_extract(self, test_agent, test_library):
Ensure the last parent id tag is set according to the W3C Phase 2 spec
"""
with test_library:
with test_library.start_span(
name="p_set",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"p_set",
[
["traceparent", "00-12345678901234567890123456789012-1234567890123456-01"],
["tracestate", "key1=value1,dd=s:2;o:rum;p:0123456789abcdef;t.dm:-4;t.usr.id:12345~"],
],
) as s1:
pass

with test_library.start_span(
name="p_invalid",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"p_invalid",
[
["traceparent", "00-12345678901234567890123456789013-1234567890123457-01"],
["tracestate", "key1=value1,dd=s:2;t.dm:-4;p:XX!X"],
],
Expand Down Expand Up @@ -798,9 +798,9 @@ def test_tracestate_w3c_p_extract_datadog_w3c(self, test_agent, test_library):
"""
with test_library:
# 1) Trace ids and parent ids in datadog and tracecontext headers match
with test_library.start_span(
name="identical_trace_info",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"identical_trace_info",
[
["traceparent", "00-11111111111111110000000000000001-000000003ade68b1-01"],
["tracestate", "dd=s:2;p:000000003ade68b1,foo=1"],
["x-datadog-trace-id", "1"],
Expand All @@ -811,9 +811,9 @@ def test_tracestate_w3c_p_extract_datadog_w3c(self, test_agent, test_library):
pass

# 2) Trace ids in datadog and tracecontext headers do not match
with test_library.start_span(
name="trace_ids_do_not_match",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"trace_ids_do_not_match",
[
["traceparent", "00-11111111111111110000000000000002-000000003ade68b1-01"],
["tracestate", "dd=s:2;p:000000000000000a,foo=1"],
["x-datadog-parent-id", "10"],
Expand All @@ -824,9 +824,9 @@ def test_tracestate_w3c_p_extract_datadog_w3c(self, test_agent, test_library):
pass

# 3) Parent ids in Datadog and tracecontext headers do not match
with test_library.start_span(
name="same_trace_non_matching_parent_ids",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"same_trace_non_matching_parent_ids",
[
["traceparent", "00-11111111111111110000000000000003-000000003ade68b1-01"],
["tracestate", "dd=s:2;p:000000000000000a,foo=1"],
["x-datadog-trace-id", "3"],
Expand All @@ -837,9 +837,9 @@ def test_tracestate_w3c_p_extract_datadog_w3c(self, test_agent, test_library):
pass

# 4) Parent ids do not match and p value is not present in tracestate
with test_library.start_span(
name="non_matching_span_missing_p_value",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"non_matching_span_missing_p_value",
[
["traceparent", "00-00000000000000000000000000000004-000000003ade68b1-01"],
["tracestate", "dd=s:2,foo=1"],
["x-datadog-trace-id", "4"],
Expand All @@ -848,10 +848,9 @@ def test_tracestate_w3c_p_extract_datadog_w3c(self, test_agent, test_library):
) as s4:
pass

# 5) Parent ids do not match and p value does not match datadog headers
with test_library.start_span(
name="non_matching_span_non_matching_p_value",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"non_matching_span_non_matching_p_value",
[
["traceparent", "00-00000000000000000000000000000005-000000003ade68b1-01"],
["tracestate", "dd=s:2;p:8fffffffffffffff,foo=1"],
["x-datadog-parent-id", "10"],
Expand Down Expand Up @@ -915,9 +914,9 @@ def test_tracestate_w3c_p_phase_3_extract_first(self, test_agent, test_library):
"""

# 1) Datadog and tracecontext headers, parent ids do not match
with test_library.start_span(
name="same_trace_different_parent_ids",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"same_trace_different_parent_ids",
[
["traceparent", "00-11111111111111110000000000000001-000000000000000f-01"],
["tracestate", "dd=s:2;p:0123456789abcdef,foo=1"],
["x-datadog-trace-id", "1"],
Expand All @@ -942,9 +941,9 @@ def test_tracestate_w3c_context_leak(self, test_agent, test_library):
Ensure high order bits do not leak between traces
"""
with test_library:
with test_library.start_span(
name="high_order_64_bits_set",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"high_order_64_bits_set",
[
["traceparent", "00-33333333333333330000000000000003-000000003ade68b1-01"],
["tracestate", "dd=s:2;p:000000000000000a,foo=1"],
["x-datadog-trace-id", "3"],
Expand All @@ -954,9 +953,9 @@ def test_tracestate_w3c_context_leak(self, test_agent, test_library):
) as s1:
pass

with test_library.start_span(
name="high_order_64_bits_unset",
http_headers=[
with test_library.extract_headers_and_make_child_span(
"high_order_64_bits_unset",
[
["traceparent", "00-00000000000000000000000000000004-000000003ade68b1-01"],
["tracestate", "dd=s:2,foo=1"],
["x-datadog-trace-id", "4"],
Expand Down
Loading

0 comments on commit 67831f8

Please sign in to comment.