Skip to content

fix(profiling): keep real proxy when only profiling is enabled#8116

Closed
szegedi wants to merge 3 commits intomasterfrom
szegedi/keep-proxy-for-profiling
Closed

fix(profiling): keep real proxy when only profiling is enabled#8116
szegedi wants to merge 3 commits intomasterfrom
szegedi/keep-proxy-for-profiling

Conversation

@szegedi
Copy link
Copy Markdown
Contributor

@szegedi szegedi commented Apr 27, 2026

Summary

When DD_TRACE_ENABLED=false (or its alias DD_TRACING_ENABLED=0), packages/dd-trace/src/index.js exports NoopProxy. 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) for DD_DYNAMIC_INSTRUMENTATION_ENABLED and DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED that keeps the real proxy alive when tracing is off. This PR adds DD_PROFILING_ENABLED to that allowlist.

DD_PROFILING_ENABLED is declared with "allowed": "false|true|auto|1|0", so the check recognizes true/1/auto as values that should keep the proxy alive (matching how proxy.js already 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 setting DD_DYNAMIC_INSTRUMENTATION_ENABLED=true; once this PR ships, that workaround can be removed.

Test plan

  • Smoke test all combinations locally:
    • DD_TRACE_ENABLED=false alone → NoopProxy
    • DD_TRACE_ENABLED=false + DD_PROFILING_ENABLED=true|1|auto → real Tracer
    • DD_TRACE_ENABLED=false + DD_PROFILING_ENABLED=falseNoopProxy
    • DD_TRACING_ENABLED=0 alone → NoopProxy (alias)
    • DD_TRACING_ENABLED=0 + DD_PROFILING_ENABLED=1 → real Tracer
  • eslint packages/dd-trace/src/index.js passes
  • CI green

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'.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

Overall package size

Self size: 5.55 MB
Deduped: 6.4 MB
No deduping: 6.4 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
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.54%. Comparing base (31624d7) to head (f550860).
⚠️ Report is 2 commits behind head on master.

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     
Flag Coverage Δ
aiguard-macos 36.35% <100.00%> (-0.26%) ⬇️
aiguard-ubuntu 36.45% <100.00%> (-0.26%) ⬇️
aiguard-windows 36.25% <100.00%> (-0.26%) ⬇️
apm-capabilities-tracing-macos 48.07% <100.00%> (+0.03%) ⬆️
apm-capabilities-tracing-ubuntu-active 48.13% <100.00%> (+0.07%) ⬆️
apm-capabilities-tracing-ubuntu-latest 48.10% <100.00%> (+0.07%) ⬆️
apm-capabilities-tracing-ubuntu-maintenance 48.13% <100.00%> (+0.07%) ⬆️
apm-capabilities-tracing-ubuntu-oldest 48.12% <100.00%> (+0.07%) ⬆️
apm-capabilities-tracing-windows 47.92% <100.00%> (+0.07%) ⬆️
apm-integrations-child-process 36.00% <100.00%> (-0.26%) ⬇️
apm-integrations-couchbase-18 35.01% <100.00%> (-0.28%) ⬇️
apm-integrations-couchbase-eol 35.09% <100.00%> (-0.25%) ⬇️
apm-integrations-oracledb 35.07% <100.00%> (-0.24%) ⬇️
appsec-express 52.68% <100.00%> (-0.25%) ⬇️
appsec-fastify 49.16% <100.00%> (-0.23%) ⬇️
appsec-graphql 49.52% <100.00%> (-0.23%) ⬇️
appsec-kafka 41.94% <100.00%> (-0.25%) ⬇️
appsec-ldapjs 41.27% <100.00%> (-0.23%) ⬇️
appsec-lodash 41.30% <100.00%> (-0.23%) ⬇️
appsec-macos 56.74% <100.00%> (-0.25%) ⬇️
appsec-mongodb-core 45.60% <100.00%> (-0.24%) ⬇️
appsec-mongoose 46.48% <100.00%> (-0.24%) ⬇️
appsec-mysql 48.65% <100.00%> (-0.23%) ⬇️
appsec-node-serialize 40.48% <100.00%> (-0.23%) ⬇️
appsec-passport 44.44% <100.00%> (-0.25%) ⬇️
appsec-postgres 48.24% <100.00%> (-0.23%) ⬇️
appsec-sourcing 39.97% <100.00%> (-0.23%) ⬇️
appsec-stripe 42.18% <100.00%> (-0.25%) ⬇️
appsec-template 40.64% <100.00%> (-0.23%) ⬇️
appsec-ubuntu 56.81% <100.00%> (-0.25%) ⬇️
appsec-windows 56.63% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-bluebird 29.72% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-body-parser 37.60% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-child_process 35.38% <100.00%> (-0.26%) ⬇️
instrumentations-instrumentation-cookie-parser 31.65% <100.00%> (-0.22%) ⬇️
instrumentations-instrumentation-express 31.86% <100.00%> (-0.22%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.77% <100.00%> (-0.22%) ⬇️
instrumentations-instrumentation-express-session 37.23% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-fs 29.39% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-generic-pool 30.53% <ø> (-0.35%) ⬇️
instrumentations-instrumentation-http 36.83% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-knex 29.69% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-light-my-request 37.17% <100.00%> (-0.24%) ⬇️
instrumentations-instrumentation-mongoose 30.78% <100.00%> (-0.22%) ⬇️
instrumentations-instrumentation-multer 37.38% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-mysql2 35.36% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-passport 41.11% <100.00%> (-0.24%) ⬇️
instrumentations-instrumentation-passport-http 40.80% <100.00%> (-0.24%) ⬇️
instrumentations-instrumentation-passport-local 41.30% <100.00%> (-0.24%) ⬇️
instrumentations-instrumentation-pg 34.88% <100.00%> (-0.25%) ⬇️
instrumentations-instrumentation-promise 29.65% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-promise-js 29.66% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-q 29.69% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-url 29.65% <100.00%> (-0.23%) ⬇️
instrumentations-instrumentation-when 29.67% <100.00%> (-0.23%) ⬇️
llmobs-ai 38.33% <100.00%> (-0.25%) ⬇️
llmobs-anthropic 37.78% <100.00%> (-0.24%) ⬇️
llmobs-bedrock 37.03% <100.00%> (-0.22%) ⬇️
llmobs-google-genai 37.46% <100.00%> (-0.24%) ⬇️
llmobs-langchain 37.04% <100.00%> (-0.20%) ⬇️
llmobs-openai 41.15% <100.00%> (-0.25%) ⬇️
llmobs-vertex-ai 37.64% <100.00%> (-0.25%) ⬇️
platform-core 30.03% <ø> (ø)
platform-esbuild 32.83% <ø> (ø)
platform-instrumentations-misc 40.01% <ø> (ø)
platform-shimmer 35.72% <ø> (ø)
platform-unit-guardrails 31.39% <ø> (ø)
platform-webpack 20.71% <100.00%> (-0.07%) ⬇️
plugins-azure-durable-functions 25.36% <ø> (ø)
plugins-azure-event-hubs 25.51% <ø> (ø)
plugins-azure-service-bus 24.92% <ø> (ø)
plugins-bullmq 40.65% <100.00%> (-0.28%) ⬇️
plugins-cassandra ?
plugins-cookie 26.47% <ø> (ø)
plugins-cookie-parser 26.28% <ø> (ø)
plugins-crypto 25.70% <ø> (ø)
plugins-dd-trace-api 35.32% <100.00%> (-0.48%) ⬇️
plugins-express-mongo-sanitize 26.42% <ø> (ø)
plugins-express-session 26.24% <ø> (ø)
plugins-fastify 39.22% <100.00%> (-0.25%) ⬇️
plugins-fetch 35.71% <100.00%> (-0.24%) ⬇️
plugins-fs 35.60% <100.00%> (-0.26%) ⬇️
plugins-generic-pool 25.40% <ø> (ø)
plugins-google-cloud-pubsub 42.96% <100.00%> (-0.26%) ⬇️
plugins-grpc 37.98% <100.00%> (-0.25%) ⬇️
plugins-handlebars 26.46% <ø> (ø)
plugins-hapi 37.22% <100.00%> (-0.25%) ⬇️
plugins-hono 37.46% <100.00%> (-0.25%) ⬇️
plugins-ioredis 35.66% <100.00%> (-0.26%) ⬇️
plugins-knex 26.14% <ø> (ø)
plugins-langgraph 34.95% <100.00%> (-0.25%) ⬇️
plugins-ldapjs 24.02% <ø> (ø)
plugins-light-my-request 25.88% <ø> (ø)
plugins-limitd-client 29.95% <100.00%> (-0.23%) ⬇️
plugins-lodash 25.47% <ø> (ø)
plugins-mariadb 36.53% <100.00%> (-0.26%) ⬇️
plugins-memcached 35.30% <100.00%> (-0.26%) ⬇️
plugins-microgateway-core 36.30% <100.00%> (-0.25%) ⬇️
plugins-modelcontextprotocol-sdk 34.24% <100.00%> (-0.25%) ⬇️
plugins-moleculer 38.00% <100.00%> (-0.25%) ⬇️
plugins-mongodb 36.47% <100.00%> (-0.24%) ⬇️
plugins-mongodb-core 36.10% <100.00%> (-0.25%) ⬇️
plugins-mongoose 35.98% <100.00%> (-0.24%) ⬇️
plugins-multer 26.24% <ø> (ø)
plugins-mysql 36.39% <100.00%> (-0.26%) ⬇️
plugins-mysql2 36.37% <100.00%> (-0.25%) ⬇️
plugins-node-serialize 26.51% <ø> (ø)
plugins-opensearch 34.97% <100.00%> (-0.24%) ⬇️
plugins-passport-http 26.30% <ø> (ø)
plugins-pino 31.76% <100.00%> (-0.24%) ⬇️
plugins-postgres 34.36% <100.00%> (-0.26%) ⬇️
plugins-process 25.70% <ø> (ø)
plugins-pug 26.47% <ø> (ø)
plugins-redis 35.86% <100.00%> (-0.26%) ⬇️
plugins-router 39.86% <100.00%> (-0.26%) ⬇️
plugins-sequelize 25.18% <ø> (ø)
plugins-test-and-upstream-amqp10 35.62% <100.00%> (-0.25%) ⬇️
plugins-test-and-upstream-amqplib 40.79% <100.00%> (-0.28%) ⬇️
plugins-test-and-upstream-apollo 36.48% <100.00%> (-0.23%) ⬇️
plugins-test-and-upstream-avsc 35.39% <100.00%> (-0.26%) ⬇️
plugins-test-and-upstream-bunyan 31.10% <100.00%> (-0.24%) ⬇️
plugins-test-and-upstream-connect 37.81% <100.00%> (-0.26%) ⬇️
plugins-test-and-upstream-graphql 37.16% <100.00%> (-0.25%) ⬇️
plugins-test-and-upstream-koa 37.42% <100.00%> (-0.25%) ⬇️
plugins-test-and-upstream-protobufjs 35.60% <100.00%> (-0.26%) ⬇️
plugins-test-and-upstream-rhea 40.87% <100.00%> (-0.30%) ⬇️
plugins-undici 36.48% <100.00%> (-0.24%) ⬇️
plugins-url 25.70% <ø> (ø)
plugins-valkey 35.21% <100.00%> (-0.37%) ⬇️
plugins-vm 25.70% <ø> (ø)
plugins-winston 31.41% <100.00%> (-0.36%) ⬇️
plugins-ws 38.94% <100.00%> (-0.26%) ⬇️
profiling-macos 37.80% <100.00%> (-0.26%) ⬇️
profiling-ubuntu 37.96% <100.00%> (-0.26%) ⬇️
profiling-windows 39.33% <100.00%> (-0.25%) ⬇️
serverless-azure-functions-client 25.25% <ø> (ø)
serverless-azure-functions-eventhubs 25.25% <ø> (ø)
serverless-azure-functions-servicebus 25.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented Apr 27, 2026

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1 Test failed

mysql2 instrumentation with mysql2 >=3.11.5 (3.11.5) "before all" hook in "with mysql2 >=3.11.5 (3.11.5)" from with mysql2 >=3.11.5 (3.11.5)   View in Datadog   (Fix with Cursor)
Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/dd-trace-js/dd-trace-js/packages/datadog-instrumentations/test/mysql2.spec.js)

Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/dd-trace-js/dd-trace-js/packages/datadog-instrumentations/test/mysql2.spec.js)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 68.15% (+0.01%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f550860 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Apr 27, 2026

Benchmarks

Benchmark execution time: 2026-04-27 14:41:04

Comparing candidate commit f550860 in PR branch szegedi/keep-proxy-for-profiling with baseline commit 31624d7 in branch master.

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

Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Shall we add a test to make sure this is working even with a refactoring? :)

szegedi added 2 commits April 27, 2026 16:24
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).
@szegedi szegedi requested a review from BridgeAR April 27, 2026 14:48
@BridgeAR
Copy link
Copy Markdown
Member

I think this is now obsolete with the other PR reverting to the former behavior. Closing

@BridgeAR BridgeAR closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants