Skip to content

Commit 4b74d31

Browse files
authored
ci(tracer): avoids shutting down the global tracer in the main process (#12235)
When the tracer is shutdown span aggregators are removed. If this is done outside of a subprocess it will impact the state of the tracer in future test runs. This PR ensures the tracer shutdown tests are only run in a subprocess. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 6a06f77 commit 4b74d31

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

tests/tracer/test_propagation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
from tests.contrib.fastapi.conftest import test_spans as fastapi_test_spans # noqa:F401
4848
from tests.contrib.fastapi.conftest import tracer # noqa:F401
4949

50-
from ..utils import flaky
5150
from ..utils import override_env
5251
from ..utils import override_global_config
5352

@@ -837,7 +836,6 @@ def test_extract_128bit_trace_ids_tracecontext():
837836
assert child_span.trace_id == trace_id
838837

839838

840-
@flaky(1735812000, reason="FIXME: Failing due to the global tracer being used in all tests")
841839
def test_last_dd_span_id():
842840
non_dd_remote_context = HTTPPropagator.extract(
843841
{

tests/tracer/test_tracer.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ def test_tracer_shutdown_timeout():
676676
mock_stop.assert_called_once_with(2)
677677

678678

679+
@pytest.mark.subprocess(
680+
err=b"Spans started after the tracer has been shut down will not be sent to the Datadog Agent.\n",
681+
)
679682
def test_tracer_shutdown():
680683
import mock
681684

@@ -691,26 +694,6 @@ def test_tracer_shutdown():
691694
mock_write.assert_not_called()
692695

693696

694-
def test_tracer_shutdown_warning():
695-
import logging
696-
697-
import mock
698-
699-
from ddtrace.trace import tracer as t
700-
701-
t.shutdown()
702-
703-
with mock.patch.object(logging.Logger, "warning") as mock_logger:
704-
with t.trace("something"):
705-
pass
706-
707-
mock_logger.assert_has_calls(
708-
[
709-
mock.call("Spans started after the tracer has been shut down will not be sent to the Datadog Agent."),
710-
]
711-
)
712-
713-
714697
@pytest.mark.skip(reason="Fails to Pickle RateLimiter in the Tracer")
715698
@pytest.mark.subprocess
716699
def test_tracer_fork():

0 commit comments

Comments
 (0)