Skip to content

feat: add config DD_TRACE_RUNTIME_ID_ENABLED #13618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddtrace/settings/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def __init__(self):
"DD_RUNTIME_METRICS_ENABLED", False, asbool, "OTEL_METRICS_EXPORTER"
)
self._runtime_metrics_runtime_id_enabled = _get_config(
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED", False, asbool
["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED", "DD_TRACE_RUNTIME_ID_ENABLED"], False, asbool
)
self._experimental_features_enabled = _get_config(
"DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED", set(), lambda x: set(x.strip().upper().split(","))
Expand Down
3 changes: 2 additions & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,11 @@ Other
These metrics track the memory management and concurrency of the python runtime.
Refer to the following `docs <https://docs.datadoghq.com/tracing/metrics/runtime_metrics/python/>` _ for more information.

DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED:
DD_TRACE_RUNTIME_ID_ENABLED:
type: Boolean
default: False
version_added:
v3.10.0: Renamed from ``DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED``
v3.2.0: Adds initial support

description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
features:
- |
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``.
19 changes: 15 additions & 4 deletions tests/runtime/test_runtime_metrics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ def test_runtime_metrics_enable_environ(monkeypatch, environ):
RuntimeMetrics.disable()


@pytest.mark.subprocess(parametrize={"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": ["true", "false"]})
@pytest.mark.subprocess(
parametrize={
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": ["true", "false"],
"DD_TRACE_RUNTIME_ID_ENABLED": ["true", "false"],
}
)
def test_runtime_metrics_experimental_runtime_tag():
"""
When runtime metrics is enabled and DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED=DD_RUNTIME_METRICS_ENABLED
Expand All @@ -217,12 +222,18 @@ def test_runtime_metrics_experimental_runtime_tag():
assert worker_instance.status == ServiceStatus.RUNNING

runtime_id_tag = f"runtime-id:{get_runtime_id()}"
if os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "true":
if (
os.environ["DD_TRACE_RUNTIME_ID_ENABLED"] == "true"
or os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "true"
):
assert runtime_id_tag in worker_instance._platform_tags, worker_instance._platform_tags
elif os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "false":
elif (
os.environ["DD_TRACE_RUNTIME_ID_ENABLED"] == "false"
or os.environ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"] == "false"
):
assert runtime_id_tag not in worker_instance._platform_tags, worker_instance._platform_tags
else:
raise pytest.fail("Invalid value for DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED")
raise pytest.fail("Invalid value for DD_TRACE_RUNTIME_ID_ENABLED or DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED")


@pytest.mark.subprocess(
Expand Down
Loading