fix(profiling): keep real proxy when only profiling is enabled#8116
fix(profiling): keep real proxy when only profiling is enabled#8116
Conversation
When DD_TRACE_ENABLED is false (or its alias DD_TRACING_ENABLED), the package switches to NoopProxy, which means init() is a no-op and the profiler never starts. This affects users who want to disable tracing but keep continuous profiling running. Add DD_PROFILING_ENABLED to the same allowlist that already lets dynamic instrumentation and standalone appsec keep the real proxy alive when tracing is disabled. Recognize the same value set as the rest of the codebase: 'true', '1', and 'auto'.
Overall package sizeSelf size: 5.55 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8116 +/- ##
==========================================
- Coverage 73.76% 73.54% -0.23%
==========================================
Files 782 782
Lines 36316 36367 +51
==========================================
- Hits 26790 26745 -45
- Misses 9526 9622 +96
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
✨ Fix all issues with BitsAI or with Cursor
|
BenchmarksBenchmark execution time: 2026-04-27 14:41:04 Comparing candidate commit f550860 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1344 metrics, 100 unstable metrics. |
BridgeAR
left a comment
There was a problem hiding this comment.
Shall we add a test to make sure this is working even with a refactoring? :)
Spawns a subprocess per env-var combination so the proxy-selection decision (which happens once at module load) can be exercised across all branches: default, DD_TRACE_ENABLED=false, the alias DD_TRACING_ENABLED=0, OTEL_TRACES_EXPORTER=none, and the allowlist escape hatches (dynamic instrumentation, standalone appsec, and the newly-added DD_PROFILING_ENABLED=true|1|auto).
|
I think this is now obsolete with the other PR reverting to the former behavior. Closing |
Summary
When
DD_TRACE_ENABLED=false(or its aliasDD_TRACING_ENABLED=0),packages/dd-trace/src/index.jsexportsNoopProxy.NoopProxy.init()is a no-op, so the profiler never starts even though the user explicitly opted into profiling. This breaks the "profiling-only, no tracing" configuration.There is already an allowlist (
shouldUseProxyWhenTracingDisabled) forDD_DYNAMIC_INSTRUMENTATION_ENABLEDandDD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLEDthat keeps the real proxy alive when tracing is off. This PR addsDD_PROFILING_ENABLEDto that allowlist.DD_PROFILING_ENABLEDis declared with"allowed": "false|true|auto|1|0", so the check recognizestrue/1/autoas values that should keep the proxy alive (matching howproxy.jsalready handles those values to start the profiler or arm the SSI heuristic).Background
This was discovered while investigating a CI regression in DataDog/prof-correctness, where node profiling scenarios stopped producing pprof files after #6982 began resolving aliases in
getValueFromEnvSources. The companion prof-correctness PR currently works around this by settingDD_DYNAMIC_INSTRUMENTATION_ENABLED=true; once this PR ships, that workaround can be removed.Test plan
DD_TRACE_ENABLED=falsealone →NoopProxyDD_TRACE_ENABLED=false+DD_PROFILING_ENABLED=true|1|auto→ realTracerDD_TRACE_ENABLED=false+DD_PROFILING_ENABLED=false→NoopProxyDD_TRACING_ENABLED=0alone →NoopProxy(alias)DD_TRACING_ENABLED=0+DD_PROFILING_ENABLED=1→ realTracereslint packages/dd-trace/src/index.jspasses