Skip to content

Commit

Permalink
ensure recursivzely defined envier items are captured in telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Oct 22, 2024
1 parent 6323201 commit f1d768f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
29 changes: 15 additions & 14 deletions ddtrace/settings/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions tests/telemetry/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit f1d768f

Please sign in to comment.