Skip to content

Commit 21f8fa5

Browse files
committed
fix: Makes the test agent report version 7.65.0 for client side stats
1 parent 3925258 commit 21f8fa5

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

tests/parametric/test_library_tracestats.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _human_stats(stats: V06StatsAggr) -> str:
2222
return str(filtered_copy)
2323

2424

25-
def enable_tracestats(sample_rate: float | None = None) -> pytest.MarkDecorator:
25+
def enable_tracestats(sample_rate: float | None = None) -> tuple[pytest.MarkDecorator, pytest.MarkDecorator]:
2626
env = {
2727
"DD_TRACE_STATS_COMPUTATION_ENABLED": "1", # reference, dotnet, python, golang
2828
"DD_TRACE_TRACER_METRICS_ENABLED": "true", # java
@@ -32,7 +32,11 @@ def enable_tracestats(sample_rate: float | None = None) -> pytest.MarkDecorator:
3232
if sample_rate is not None:
3333
assert 0 <= sample_rate <= 1.0
3434
env.update({"DD_TRACE_SAMPLE_RATE": str(sample_rate)})
35-
return parametrize("library_env", [env])
35+
36+
# Java tracer requires agent version >= 7.65.0 for client-side stats
37+
agent_env_config = {"TEST_AGENT_VERSION": "7.65.0"}
38+
39+
return (parametrize("library_env", [env]), parametrize("agent_env", [agent_env_config]))
3640

3741

3842
@scenarios.parametric
@@ -45,7 +49,7 @@ class Test_Library_Tracestats:
4549
@missing_feature(context.library == "ruby", reason="ruby has not implemented stats computation yet")
4650
@bug(context.library >= "[email protected]", reason="APMSP-2074")
4751
def test_metrics_msgpack_serialization_TS001(
48-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
52+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
4953
):
5054
"""When spans are finished
5155
Each trace has stats metrics computed for it serialized properly in msgpack format with required fields
@@ -101,7 +105,7 @@ def test_metrics_msgpack_serialization_TS001(
101105
@missing_feature(context.library == "ruby", reason="ruby has not implemented stats computation yet")
102106
@bug(context.library >= "[email protected]", reason="APMSP-2074")
103107
def test_distinct_aggregationkeys_TS003(
104-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
108+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
105109
):
106110
"""When spans are created with a unique set of dimensions
107111
Each span has stats computed for it and is in its own bucket
@@ -189,7 +193,7 @@ def test_distinct_aggregationkeys_TS003(
189193
@enable_tracestats()
190194
@bug(context.library >= "[email protected]", reason="APMSP-2074")
191195
def test_measured_spans_TS004(
192-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
196+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
193197
):
194198
"""When spans are marked as measured
195199
Each has stats computed for it
@@ -233,7 +237,7 @@ def test_measured_spans_TS004(
233237
@missing_feature(context.library == "ruby", reason="ruby has not implemented stats computation yet")
234238
@enable_tracestats()
235239
@bug(context.library >= "[email protected]", reason="APMSP-2074")
236-
def test_top_level_TS005(self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary):
240+
def test_top_level_TS005(self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary):
237241
"""When top level (service entry) spans are created
238242
Each top level span has trace stats computed for it.
239243
"""
@@ -286,7 +290,7 @@ def test_top_level_TS005(self, library_env: dict[str, str], test_agent: TestAgen
286290
@enable_tracestats()
287291
@bug(context.library >= "[email protected]", reason="APMSP-2074")
288292
def test_successes_errors_recorded_separately_TS006(
289-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
293+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
290294
):
291295
"""When spans are marked as errors
292296
The errors count is incremented appropriately and the stats are aggregated into the ErrorSummary
@@ -343,7 +347,7 @@ def test_successes_errors_recorded_separately_TS006(
343347
@missing_feature(context.library == "ruby", reason="ruby has not implemented stats computation yet")
344348
@enable_tracestats(sample_rate=0.0)
345349
@bug(context.library >= "[email protected]", reason="APMSP-2074")
346-
def test_sample_rate_0_TS007(self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary):
350+
def test_sample_rate_0_TS007(self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary):
347351
"""When the sample rate is 0 and trace stats is enabled
348352
non-P0 traces should be dropped
349353
trace stats should be produced
@@ -366,7 +370,7 @@ def test_sample_rate_0_TS007(self, library_env: dict[str, str], test_agent: Test
366370
@missing_feature(reason="relative error test is broken")
367371
@enable_tracestats()
368372
def test_relative_error_TS008(
369-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
373+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
370374
):
371375
"""When trace stats are computed for traces
372376
The stats should be accurate to within 1% of the real values
@@ -417,7 +421,7 @@ def test_relative_error_TS008(
417421
@enable_tracestats()
418422
@bug(context.library >= "[email protected]", reason="APMSP-2074")
419423
def test_metrics_computed_after_span_finsh_TS009(
420-
self, library_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
424+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
421425
):
422426
"""When trace stats are computed for traces
423427
Metrics must be computed after spans are finished, otherwise components of the aggregation key may change after

tests/parametric/test_span_sampling.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,9 @@ def test_child_span_selected_by_sss015(self, test_agent: TestAgentAPI, test_libr
695695
}
696696
],
697697
)
698+
@pytest.mark.parametrize("agent_env", [{"TEST_AGENT_VERSION": "7.65.0"}])
698699
def test_root_span_selected_and_child_dropped_by_sss_when_dropping_policy_is_active016(
699-
self, test_agent: TestAgentAPI, test_library: APMLibrary
700+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
700701
):
701702
"""Single spans selected by SSS must be kept and other spans expected to be dropped on the tracer side when
702703
dropping policy is active when tracer metrics enabled.
@@ -768,8 +769,9 @@ def test_root_span_selected_and_child_dropped_by_sss_when_dropping_policy_is_act
768769
}
769770
],
770771
)
772+
@pytest.mark.parametrize("agent_env", [{"TEST_AGENT_VERSION": "7.65.0"}])
771773
def test_child_span_selected_and_root_dropped_by_sss_when_dropping_policy_is_active017(
772-
self, test_agent: TestAgentAPI, test_library: APMLibrary
774+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
773775
):
774776
"""Single spans selected by SSS must be kept and other spans expected to be dropped on the tracer side when
775777
dropping policy is active when tracer metrics enabled.
@@ -835,8 +837,9 @@ def test_child_span_selected_and_root_dropped_by_sss_when_dropping_policy_is_act
835837
}
836838
],
837839
)
840+
@pytest.mark.parametrize("agent_env", [{"TEST_AGENT_VERSION": "7.65.0"}])
838841
def test_entire_trace_dropped_when_dropping_policy_is_active018(
839-
self, test_agent: TestAgentAPI, test_library: APMLibrary
842+
self, library_env: dict[str, str], agent_env: dict[str, str], test_agent: TestAgentAPI, test_library: APMLibrary
840843
):
841844
"""The entire dropped span expected to be dropped on the tracer side when
842845
dropping policy is active, which is the case when tracer metrics enabled.

utils/_context/_scenarios/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class _Scenarios:
8181
"DD_TRACE_FEATURES": "discovery",
8282
"DD_TRACE_TRACER_METRICS_ENABLED": "true", # java
8383
},
84+
agent_env={
85+
"TEST_AGENT_VERSION": "7.65.0", # Required for Java tracer >= 1.54.0 client-side stats
86+
},
8487
doc=(
8588
"End to end testing with DD_TRACE_COMPUTE_STATS=1. This feature compute stats at tracer level, and"
8689
"may drop some of them"

0 commit comments

Comments
 (0)