Skip to content

Commit d56b98b

Browse files
authored
Expect propagation tags in the first span of each trace chunk (#7426)
Co-authored-by: sarah.chen <sarah.chen@datadoghq.com>
1 parent a502326 commit d56b98b

6 files changed

Lines changed: 57 additions & 1 deletion

File tree

manifests/cpp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ manifest:
242242
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing: '>=2.0.0' # Modified by easy win activation script
243243
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span: missing_feature # Created by easy win activation script
244244
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span_default: missing_feature # Created by easy win activation script
245+
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_propagation_tags: missing_feature # Created by easy win activation script
245246
tests/parametric/test_process_discovery.py::Test_ProcessDiscovery: ">1.0.0"
246247
tests/parametric/test_process_discovery.py::Test_ProcessDiscovery::test_metadata_content_with_process_tags: # Modified by easy win activation script
247248
- declaration: bug (APMAPI-1744)

manifests/java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3962,6 +3962,7 @@ manifest:
39623962
tests/parametric/test_parametric_endpoints.py::Test_Parametric_Write_Log::test_write_log: incomplete_test_app (Logs endpoint is only implemented in python and node.js app)
39633963
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span: 'missing_feature (java uses ''>'' so it needs one more span to force a partial flush)'
39643964
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span_default: 'missing_feature (java uses ''>'' so it needs one more span to force a partial flush)'
3965+
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_propagation_tags: v1.65.0-SNAPSHOT+7071ae2ed6
39653966
tests/parametric/test_process_discovery.py::Test_ProcessDiscovery: v1.55.0-SNAPSHOT
39663967
tests/parametric/test_sampling_manual.py::Test_Manual_Sampling: v1.59.0-SNAPSHOT+419da213f7
39673968
tests/parametric/test_sampling_span_tags.py::Test_Knuth_Sample_Rate: v1.61.0-SNAPSHOT # https://github.com/DataDog/dd-trace-java/pull/10802

manifests/ruby.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,7 @@ manifest:
24172417
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing: '>=2.27.0' # Modified by easy win activation script
24182418
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span: missing_feature # Created by easy win activation script
24192419
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span_default: missing_feature # Created by easy win activation script
2420+
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_propagation_tags: missing_feature # Created by easy win activation script
24202421
tests/parametric/test_process_discovery.py::Test_ProcessDiscovery: v2.18.0
24212422
tests/parametric/test_sampling_delegation.py::Test_Decisionless_Extraction: v2.4.0
24222423
tests/parametric/test_sampling_span_tags.py::Test_Knuth_Sample_Rate: v2.31.0-dev

manifests/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ manifest:
296296
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing: '>=0.2.1' # Modified by easy win activation script
297297
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span: missing_feature # Created by easy win activation script
298298
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span_default: missing_feature # Created by easy win activation script
299+
tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_propagation_tags: missing_feature # Created by easy win activation script
299300
tests/parametric/test_process_discovery.py: missing_feature
300301
tests/parametric/test_sampling_manual.py::Test_Manual_Sampling: missing_feature
301302
tests/parametric/test_sampling_span_tags.py: '>=0.2.1' # Modified by easy win activation script

tests/parametric/test_partial_flushing.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from utils.docker_fixtures.spec.trace import find_span, find_trace
2+
from utils.docker_fixtures.spec.trace import find_first_span_in_trace_payload, find_span, find_trace
33
from utils import features, scenarios
44
from utils.docker_fixtures import TestAgentAPI
55
from .conftest import APMLibrary
@@ -24,6 +24,23 @@ def test_partial_flushing_one_span_default(self, test_agent: TestAgentAPI, test_
2424
"""
2525
self.do_partial_flush_test(test_agent, test_library)
2626

27+
@pytest.mark.parametrize(
28+
"library_env",
29+
[
30+
{
31+
"DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED": "true",
32+
"DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "2",
33+
"DD_TRACE_PARTIAL_FLUSH_ENABLED": "true",
34+
"DD_TRACE_SAMPLE_RATE": "1",
35+
}
36+
],
37+
)
38+
def test_partial_flushing_propagation_tags(self, test_agent: TestAgentAPI, test_library: APMLibrary) -> None:
39+
"""Create a trace with a root span and two children. Finish the children, and ensure
40+
partial flushing places propagation tags on the first span in the chunk.
41+
"""
42+
self.do_propagation_tags_test(test_agent, test_library)
43+
2744
@pytest.mark.parametrize(
2845
"library_env", [{"DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "5", "DD_TRACE_PARTIAL_FLUSH_ENABLED": "true"}]
2946
)
@@ -65,6 +82,38 @@ def do_partial_flush_test(self, test_agent: TestAgentAPI, test_library: APMLibra
6582
assert len(traces) == 1
6683
assert root_span["name"] == "root"
6784

85+
def do_propagation_tags_test(self, test_agent: TestAgentAPI, test_library: APMLibrary) -> None:
86+
"""Create a trace with a root span and two children. Finish the children, and ensure
87+
partial flushing emits them in a chunk before the root.
88+
"""
89+
with test_library, test_library.dd_start_span(name="root") as parent_span:
90+
child_span_ids: dict[str, int | str] = {}
91+
for child_name in ("child1", "child2"):
92+
with test_library.dd_start_span(name=child_name, parent_id=parent_span.span_id) as child_span:
93+
child_span_ids[child_name] = child_span.span_id
94+
95+
partial_traces = test_agent.wait_for_num_traces(1, clear=True, wait_loops=30, sort_by_start=False)
96+
partial_trace = find_trace(partial_traces, parent_span.trace_id)
97+
assert len(partial_trace) == 2
98+
for child_name, child_span_id in child_span_ids.items():
99+
assert find_span(partial_trace, child_span_id)["name"] == child_name
100+
101+
first_span = find_first_span_in_trace_payload(partial_trace)
102+
assert first_span["metrics"]["_sampling_priority_v1"] == 2.0
103+
assert first_span["meta"]["_dd.p.tid"]
104+
assert first_span["meta"]["_dd.p.dm"] == "-3"
105+
for later_span in partial_trace[1:]:
106+
assert "_dd.p.dm" not in later_span.get("meta", {})
107+
108+
traces = test_agent.wait_for_num_traces(1, clear=True, sort_by_start=False)
109+
full_trace = find_trace(traces, parent_span.trace_id)
110+
root_span = find_span(full_trace, parent_span.span_id)
111+
assert len(traces) == 1
112+
assert root_span["name"] == "root"
113+
assert root_span == find_first_span_in_trace_payload(full_trace)
114+
assert root_span["meta"]["_dd.p.tid"]
115+
assert root_span["meta"]["_dd.p.dm"] == "-3"
116+
68117
def no_partial_flush_test(self, test_agent: TestAgentAPI, test_library: APMLibrary):
69118
"""Create a trace with a root span and one child. Finish the child, and ensure
70119
partial flushing does NOT trigger.

tests/test_the_test/scenarios.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,6 +5079,9 @@
50795079
"tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_one_span_default[library_env0]": [
50805080
"PARAMETRIC"
50815081
],
5082+
"tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_propagation_tags[library_env0]": [
5083+
"PARAMETRIC"
5084+
],
50825085
"tests/parametric/test_partial_flushing.py::Test_Partial_Flushing::test_partial_flushing_under_limit_one_payload[library_env0]": [
50835086
"PARAMETRIC"
50845087
],

0 commit comments

Comments
 (0)