|
20 | 20 | from .conftest import APMLibrary |
21 | 21 |
|
22 | 22 |
|
| 23 | +def _wait_for_client_side_stats_active(test_agent: TestAgentAPI, test_library: APMLibrary) -> None: |
| 24 | + """Wait until client-side stats are active before asserting p0 dropping. |
| 25 | +
|
| 26 | + p0 dropping only turns on after the tracer's async `/info` handshake; spans flushed before it |
| 27 | + are forwarded undropped (a startup race). A received `/v0.6/stats` payload proves it is active. |
| 28 | + """ |
| 29 | + for _ in range(30): |
| 30 | + with test_library, test_library.dd_start_span(name="css-warmup", service="webserver"): |
| 31 | + pass |
| 32 | + try: |
| 33 | + test_agent.wait_for_num_v06_stats(1, wait_loops=10) |
| 34 | + except ValueError: |
| 35 | + continue |
| 36 | + test_agent.clear() |
| 37 | + return |
| 38 | + raise ValueError("client-side stats were not enabled in time; cannot reliably assert p0 dropping") |
| 39 | + |
| 40 | + |
23 | 41 | @features.single_span_sampling |
24 | 42 | @scenarios.parametric |
25 | 43 | class Test_Span_Sampling: |
@@ -625,6 +643,7 @@ def test_root_span_selected_and_child_dropped_by_sss_when_dropping_policy_is_act |
625 | 643 | the activate dropping policy. |
626 | 644 | """ |
627 | 645 | assert test_agent.info()["client_drop_p0s"] is True, "Client drop p0s expected to be enabled" |
| 646 | + _wait_for_client_side_stats_active(test_agent, test_library) |
628 | 647 |
|
629 | 648 | with test_library, test_library.dd_start_span(name="parent", service="webserver"): |
630 | 649 | pass |
@@ -684,6 +703,7 @@ def test_child_span_selected_and_root_dropped_by_sss_when_dropping_policy_is_act |
684 | 703 | the activate dropping policy. |
685 | 704 | """ |
686 | 705 | assert test_agent.info()["client_drop_p0s"] is True, "Client drop p0s expected to be enabled" |
| 706 | + _wait_for_client_side_stats_active(test_agent, test_library) |
687 | 707 |
|
688 | 708 | with ( |
689 | 709 | test_library, |
@@ -737,6 +757,7 @@ def test_entire_trace_dropped_when_dropping_policy_is_active018( |
737 | 757 | the activate dropping policy. |
738 | 758 | """ |
739 | 759 | assert test_agent.info()["client_drop_p0s"] is True, "Client drop p0s expected to be enabled" |
| 760 | + _wait_for_client_side_stats_active(test_agent, test_library) |
740 | 761 |
|
741 | 762 | with test_library, test_library.dd_start_span(name="parent", service="webserver"): |
742 | 763 | pass |
|
0 commit comments