Skip to content

Commit 0e795ab

Browse files
authored
feat: add config DD_TRACE_RUNTIME_ID_ENABLED (#13618)
## 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 7c6df02 commit 0e795ab

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

ddtrace/settings/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def __init__(self):
535535
"DD_RUNTIME_METRICS_ENABLED", False, asbool, "OTEL_METRICS_EXPORTER"
536536
)
537537
self._runtime_metrics_runtime_id_enabled = _get_config(
538-
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED", False, asbool
538+
["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED", "DD_TRACE_RUNTIME_ID_ENABLED"], False, asbool
539539
)
540540
self._experimental_features_enabled = _get_config(
541541
"DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED", set(), lambda x: set(x.strip().upper().split(","))

docs/configuration.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,11 @@ Other
856856
These metrics track the memory management and concurrency of the python runtime.
857857
Refer to the following `docs <https://docs.datadoghq.com/tracing/metrics/runtime_metrics/python/>` _ for more information.
858858

859-
DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED:
859+
DD_TRACE_RUNTIME_ID_ENABLED:
860860
type: Boolean
861861
default: False
862862
version_added:
863+
v3.10.0: Renamed from ``DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED``
863864
v3.2.0: Adds initial support
864865

865866
description: |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
tracer: Adds the environment variable ``DD_TRACE_RUNTIME_ID_ENABLED`` to enable runtime metrics for tagging runtime metrics with the current runtime ID. This is useful for tracking runtime metrics across multiple processes. Previously, this was ``DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED``.

tests/runtime/test_runtime_metrics_api.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ def test_runtime_metrics_enable_environ(monkeypatch, environ):
198198
RuntimeMetrics.disable()
199199

200200

201-
@pytest.mark.subprocess(parametrize={"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": ["true", "false"]})
201+
@pytest.mark.subprocess(
202+
parametrize={
203+
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": ["true", "false"],
204+
"DD_TRACE_RUNTIME_ID_ENABLED": ["true", "false"],
205+
}
206+
)
202207
def test_runtime_metrics_experimental_runtime_tag():
203208
"""
204209
When runtime metrics is enabled and DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED=DD_RUNTIME_METRICS_ENABLED
@@ -217,12 +222,18 @@ def test_runtime_metrics_experimental_runtime_tag():
217222
assert worker_instance.status == ServiceStatus.RUNNING
218223

219224
runtime_id_tag = f"runtime-id:{get_runtime_id()}"
220-
if os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "true":
225+
if (
226+
os.environ["DD_TRACE_RUNTIME_ID_ENABLED"] == "true"
227+
or os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "true"
228+
):
221229
assert runtime_id_tag in worker_instance._platform_tags, worker_instance._platform_tags
222-
elif os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "false":
230+
elif (
231+
os.environ["DD_TRACE_RUNTIME_ID_ENABLED"] == "false"
232+
or os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "false"
233+
):
223234
assert runtime_id_tag not in worker_instance._platform_tags, worker_instance._platform_tags
224235
else:
225-
raise pytest.fail("Invalid value for DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED")
236+
raise pytest.fail("Invalid value for DD_TRACE_RUNTIME_ID_ENABLED or DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED")
226237

227238

228239
@pytest.mark.subprocess(

0 commit comments

Comments
 (0)