Skip to content

Emit env var names in telemetry config#3783

Merged
bm1549 merged 5 commits intomasterfrom
worktree-brian.marks+telemetry-env-var-names
Apr 15, 2026
Merged

Emit env var names in telemetry config#3783
bm1549 merged 5 commits intomasterfrom
worktree-brian.marks+telemetry-env-var-names

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented Apr 13, 2026

Summary

  • Telemetry config names now use the canonical environment variable name (e.g. DD_TRACE_GENERATE_ROOT_SPAN) instead of the INI-derived dot notation (e.g. trace.generate_root_span)
  • Uses cfg->names[0] directly from the memoized config entry, which is the original env var name from the CONFIG() macro definitions
  • No performance impact — names[0] is a stack-allocated buffer already in memory

Motivation

The backend automatically opens PRs that map config telemetry based on the config registry. Previously, PHP emitted INI-derived names like trace.generate_root_span which don't match the env var names in the registry, so those auto-generated PRs couldn't map PHP configs correctly. By emitting the standard env var name (e.g. DD_TRACE_GENERATE_ROOT_SPAN), the auto-generated backend PRs can map PHP configs without issues.

Companion PR

Test plan

  • tests/ext/telemetry/config.phpt — verifies telemetry config names are emitted as env var names
  • tests/ext/library_config/fleet_config.phpt — verifies fleet stable config telemetry names
  • tests/ext/library_config/local_config.phpt — verifies local stable config telemetry names
  • tests/ext/appsec/sca_flag_is_sent_*.phpt (5 tests) — verifies SCA config telemetry names
  • All tests pass locally in Docker (php-8.3_bookworm-6, debug build)

🤖 Generated with Claude Code

Use the canonical environment variable name (e.g. DD_TRACE_GENERATE_ROOT_SPAN)
directly from cfg->names[0] instead of stripping the "datadog." prefix from the
PHP INI name (e.g. trace.generate_root_span). This is more correct as it uses
the original source-of-truth name without any lossy round-trip transformation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bm1549 bm1549 added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Apr 13, 2026
@datadog-prod-us1-4
Copy link
Copy Markdown

datadog-prod-us1-4 Bot commented Apr 13, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Other Violations

🧪 1 Test failed

tests.parametric.test_telemetry.Test_Stable_Configuration_Origin.test_stable_configuration_origin_extended_configs_good_use_case[local_cfg0-library_env0-fleet_cfg0-expected_origins0, parametric-php] from system_tests_suite   View in Datadog   (Fix with Cursor)
assert None is not None

self = <tests.parametric.test_telemetry.Test_Stable_Configuration_Origin object at 0x7fd3ac4b4f50>
local_cfg = {'DD_TAGS': 'tag1:value1,tag2:value2', 'DD_TRACE_PROPAGATION_STYLE': 'tracecontext'}
fleet_cfg = {'DD_TRACE_PROPAGATION_STYLE': 'datadog'}
test_agent = <utils.docker_fixtures._test_agent.TestAgentAPI object at 0x7fd3ab538fb0>
test_library = <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fd3ab539280>
expected_origins = {'tags': 'local_stable_config', 'trace_propagation_style': 'fleet_stable_config'}

    @pytest.mark.parametrize(
...

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.70% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fca7105 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Apr 13, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-04-13 23:47:17

Comparing candidate commit fca7105 in PR branch worktree-brian.marks+telemetry-env-var-names with baseline commit df43587 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 192 metrics, 2 unstable metrics.

bm1549 and others added 4 commits April 13, 2026 17:36
The SCA tests expected the old INI-derived name "appsec.sca_enabled" but
the telemetry now emits the env var name "DD_APPSEC_SCA_ENABLED".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The sca_test.inc helper uses strpos() to find "sca_enabled" in the config
name, but the env var name DD_APPSEC_SCA_ENABLED is uppercase. Switch to
stripos() for case-insensitive matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
DD_APPSEC_SCA_ENABLED is 21 characters, not 22.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :-)

@bm1549 bm1549 marked this pull request as ready for review April 15, 2026 14:12
@bm1549 bm1549 requested a review from a team as a code owner April 15, 2026 14:12
@bm1549 bm1549 merged commit 6cee576 into master Apr 15, 2026
2099 checks passed
@bm1549 bm1549 deleted the worktree-brian.marks+telemetry-env-var-names branch April 15, 2026 14:36
@github-actions github-actions Bot added this to the 1.19.0 milestone Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants