Skip to content

Commit e141099

Browse files
authored
chore(telemetry): avoid starting the telemetry after a process forks (backport #3984) (#3995)
This is an automatic backport of pull request #3984 done by [Mergify](https://mergify.com). --- <details> <summary>Mergify commands and options</summary> <br /> More conditions and actions can be found in the [documentation](https://docs.mergify.com/). You can also trigger Mergify actions by commenting on this pull request: - `@Mergifyio refresh` will re-evaluate the rules - `@Mergifyio rebase` will rebase this PR on its base branch - `@Mergifyio update` will merge the base branch into this PR - `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch Additionally, on Mergify [dashboard](https://dashboard.mergify.com/) you can: - look at your merge queues - generate the Mergify configuration with the config editor. Finally, you can contact us on https://mergify.com </details>
1 parent 6851793 commit e141099

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ddtrace/internal/telemetry/writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ def _fork_writer(self):
241241
# Avoid sending duplicate events.
242242
# Queued events should be sent in the main process.
243243
self._reset_queues()
244-
self.start()
245244

246245
def disable(self):
247246
# type: () -> None

tests/tracer/telemetry/test_telemetry.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,21 @@ def test_fork():
6363
assert telemetry.telemetry_writer.status == ServiceStatus.RUNNING
6464
# Kill the process so it doesn't continue running the rest of the test suite
6565
os._exit(0)
66+
67+
68+
def test_logs_after_fork(ddtrace_run_python_code_in_subprocess):
69+
# Regression test: telemetry writer should not log an error when a process forks
70+
_, err, status, _ = ddtrace_run_python_code_in_subprocess(
71+
"""
72+
import ddtrace
73+
import logging
74+
import os
75+
76+
logging.basicConfig() # required for python 2.7
77+
ddtrace.internal.telemetry.telemetry_writer.enable()
78+
os.fork()
79+
""",
80+
)
81+
82+
assert status == 0, err
83+
assert err == b""

0 commit comments

Comments
 (0)