@@ -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
0 commit comments