From f1d768f8e96cbc4655727e4093386398f2770de3 Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Tue, 22 Oct 2024 13:15:17 -0400 Subject: [PATCH] ensure recursivzely defined envier items are captured in telemetry --- ddtrace/settings/_core.py | 29 +++++++++++++++-------------- tests/telemetry/test_writer.py | 9 +++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ddtrace/settings/_core.py b/ddtrace/settings/_core.py index ea351deac3c..41eba3b686f 100644 --- a/ddtrace/settings/_core.py +++ b/ddtrace/settings/_core.py @@ -19,23 +19,24 @@ def __init__(self, *args, **kwargs): self._report_telemetry() def _report_telemetry(self) -> None: - for name, e in list(self.items()): - if isinstance(e, EnvVariable) and not e.private: - env_name = e.full_name + for name, e in self.items(recursive=True): + if not isinstance(e, EnvVariable) or e.private: + continue + env_name = e.full_name - # Get the item value recursively - env_val = self - for p in name.split("."): - env_val = getattr(env_val, p) + # Get the item value recursively + env_val = self + for p in name.split("."): + env_val = getattr(env_val, p) - source = "unknown" - if env_name in self.source: - source = "env_var" - else: - if env_val == e.default: - source = "default" + source = "unknown" + if env_name in self.source: + source = "env_var" + else: + if env_val == e.default: + source = "default" - telemetry_writer.add_configuration(env_name, env_val, source) + telemetry_writer.add_configuration(env_name, env_val, source) def report_telemetry(env: Env) -> None: diff --git a/tests/telemetry/test_writer.py b/tests/telemetry/test_writer.py index f30729eae75..6adfa019cc1 100644 --- a/tests/telemetry/test_writer.py +++ b/tests/telemetry/test_writer.py @@ -386,12 +386,21 @@ def test_app_started_event_configuration_override(test_agent_session, run_python {"name": "DD_PROFILING_ENABLE_ASSERTS", "origin": "default", "value": False}, {"name": "DD_PROFILING_ENABLE_CODE_PROVENANCE", "origin": "default", "value": True}, {"name": "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", "origin": "default", "value": True}, + {"name": "DD_PROFILING_EXPORT_LIBDD_ENABLED", "origin": "default", "value": False}, + {"name": "DD_PROFILING_HEAP_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_HEAP_SAMPLE_SIZE", "origin": "default", "value": None}, {"name": "DD_PROFILING_IGNORE_PROFILER", "origin": "default", "value": False}, + {"name": "DD_PROFILING_LOCK_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_LOCK_NAME_INSPECT_DIR", "origin": "default", "value": True}, {"name": "DD_PROFILING_MAX_EVENTS", "origin": "default", "value": 16384}, {"name": "DD_PROFILING_MAX_FRAMES", "origin": "env_var", "value": 512}, {"name": "DD_PROFILING_MAX_TIME_USAGE_PCT", "origin": "default", "value": 1.0}, + {"name": "DD_PROFILING_MEMORY_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_MEMORY_EVENTS_BUFFER", "origin": "default", "value": 16}, {"name": "DD_PROFILING_OUTPUT_PPROF", "origin": "default", "value": None}, {"name": "DD_PROFILING_SAMPLE_POOL_CAPACITY", "origin": "default", "value": 4}, + {"name": "DD_PROFILING_STACK_ENABLED", "origin": "env_var", "value": False}, + {"name": "DD_PROFILING_STACK_V2_ENABLED", "origin": "default", "value": False}, {"name": "DD_PROFILING_TAGS", "origin": "default", "value": ""}, {"name": "DD_PROFILING_TIMELINE_ENABLED", "origin": "default", "value": False}, {"name": "DD_PROFILING_UPLOAD_INTERVAL", "origin": "env_var", "value": 10.0},