feat(profiling): report the profiler's running state in telemetry #11445
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 369 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.354
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11445"
general
weight: 0.35
IlyasShabi
What does this PR do?
Reports whether the profiler actually runs through instrumentation telemetry:
app-product-change: sent withproducts.profiler = { version, enabled }whenever the profiler starts or stops, including when it stops itself after a failed collection, and when a start fails. It is sent immediately, and only when the state differs from the last one sent.app-started(and the extended heartbeat, which resends it) reports the profiler as enabled only forDD_PROFILING_ENABLED=true. Underauto, the SSI heuristics may never start the profiler, so it starts out reported as disabled, andapp-product-changereports it once it starts. Previouslyautowas reported as enabled.How:
profiling/profiler.js) emitsenabledChangedwhenever its running state changes.profiler.js) reports the outcome of each decision to telemetry in a microtask rather than every step, so a restart for changed settings (stop, then start again, possibly after the final export) doesn't report the profiler as stopped. A stop that retracts a pending restart, or a deferred configuration that leaves the profiler stopped, does report it.telemetry/telemetry.js) compares with what it last sent inapp-startedorapp-product-change. A state reported beforeapp-startedgoes intoapp-startedinstead. A change also replaces an earlier one still waiting to be retried: retries are batched after the new request, so the intake would otherwise end up with the outdated state.Motivation
Remote enablement of the profiler (
APM_PROFILING, #10905) gives the caller, for example an agent using the profiling MCP, no way to confirm that profiling started short of waiting for the first profile. The telemetry intake already recordsproducts.profiler.enabledper runtime ID fromapp-startedandapp-product-change, and makes it queryable (apm_tables.service_session.profiler_enabled), but dd-trace-js only reported the configured value at startup. dd-trace-py already sendsapp-product-changewhen its profiler starts and stops.Additional Notes
Checked end to end against Datadog staging with an app (Node.js 26) running this branch,
DD_PROFILING_ENABLED=falselocally, enabled and disabled throughAPM_PROFILING:app-startedrecordedprofiler_enabled: false.profiler_enabled: true7 s later, and it was queryable through DDSQL about 17 s after the start.profiler_enabled: false2.6 s after the stop, queryable about 28 s after it.For comparison, dd-trace-py sends the event with its next 60-second heartbeat, which took 47–56 s end to end in the same setup.
Jira: [PROF-16285]
[PROF-16285]: https://datadoghq.atlassian.net/browse/PROF-16285?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ