← Back to Pull requests

feat(profiling): report the profiler's running state in telemetry #11445

Closed
unknown closed this pull request without merging on Dec 01, 2026 15:47 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 13:48 UTC
Author

What does this PR do?

Reports whether the profiler actually runs through instrumentation telemetry:

  • app-product-change: sent with products.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 for DD_PROFILING_ENABLED=true. Under auto, the SSI heuristics may never start the profiler, so it starts out reported as disabled, and app-product-change reports it once it starts. Previously auto was reported as enabled.
  • How:

  • The profiling engine (profiling/profiler.js) emits enabledChanged whenever its running state changes.

  • The coordinator (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/telemetry.js) compares with what it last sent in app-started or app-product-change. A state reported before app-started goes into app-started instead. 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 records products.profiler.enabled per runtime ID from app-started and app-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 sends app-product-change when 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=false locally, enabled and disabled through APM_PROFILING:

  • app-started recorded profiler_enabled: false.

  • Enabling: the profiler started on delivery, the intake recorded profiler_enabled: true 7 s later, and it was queryable through DDSQL about 17 s after the start.

  • Disabling: recorded profiler_enabled: false 2.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

    Diff: 369 lines (+276 / -93) across 4 files Reviewer: IlyasShabi Review duration: 8759m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%