Skip to content

Commit 355df5e

Browse files
test(runtime-metrics): test env variable (#2567)
Add a test case to ensure that ddtrace-run behaves as expected based on the value of the DD_RUNTIME_METRICS_ENABLED environment variable. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent ff13d1c commit 355df5e

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/runtime/test_runtime_metrics_api.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_runtime_metrics_api_idempotency():
2727
def test_manually_start_runtime_metrics(run_python_code_in_subprocess):
2828
"""
2929
When importing and manually starting runtime metrics
30-
There are no errors
30+
Runtime metrics worker starts and there are no errors
3131
"""
3232
out, err, status, pid = run_python_code_in_subprocess(
3333
"""
@@ -43,3 +43,27 @@ def test_manually_start_runtime_metrics(run_python_code_in_subprocess):
4343
)
4444

4545
assert status == 0
46+
47+
48+
def test_start_runtime_metrics_via_env_var(ddtrace_run_python_code_in_subprocess):
49+
"""
50+
When running with ddtrace-run and DD_RUNTIME_METRICS_ENABLED is set
51+
Runtime metrics worker starts and there are no errors
52+
"""
53+
54+
_, _, status, _ = ddtrace_run_python_code_in_subprocess(
55+
"""
56+
from ddtrace.internal.runtime.runtime_metrics import RuntimeWorker
57+
assert RuntimeWorker._instance is None
58+
"""
59+
)
60+
assert status == 0
61+
62+
_, _, status, _ = ddtrace_run_python_code_in_subprocess(
63+
"""
64+
from ddtrace.internal.runtime.runtime_metrics import RuntimeWorker
65+
assert RuntimeWorker._instance is not None
66+
""",
67+
env={"DD_RUNTIME_METRICS_ENABLED": "true"},
68+
)
69+
assert status == 0

0 commit comments

Comments
 (0)