Skip to content

feat(profiling): export profiles as OTLP with OTEL_PROFILES_EXPORTER=otlp - #11229

Draft
szegedi wants to merge 10 commits into
masterfrom
attila/otlp-profiles
Draft

szegedi wants to merge 10 commits into
masterfrom
attila/otlp-profiles

Conversation

@szegedi

@szegedi szegedi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds OTLP export of profiles. With OTEL_PROFILES_EXPORTER=otlp, the profiler sends each collection cycle as one OTLP ExportProfilesServiceRequest to OTEL_EXPORTER_OTLP_PROFILES_ENDPOINT, in place of the agent destination. DD_PROFILING_EXPORTERS keeps choosing destinations; file also writes the request.

  • Configuration:
    • OTEL_PROFILES_EXPORTER (none|otlp). none disables profiling unless DD_PROFILING_ENABLED is set, as OTEL_TRACES_EXPORTER=none does for tracing.
    • OTEL_EXPORTER_OTLP_PROFILES_{ENDPOINT,HEADERS,PROTOCOL,TIMEOUT}, which fall back to the generic OTEL_EXPORTER_OTLP_*. The protocol is http/protobuf only.
    • The endpoint defaults like the other signals', with the profiles signal's /v1development/profiles path, or the agentless otlp.<site> intake with the API key.
  • Collection: profilers now capture their profiles, and the profiler visits them afterwards, so pprof and OTLP differ only in the visitor.
    • capture() replaces the profilers' profile() and encode(). The wall and space profilers use @datadog/pprof's time.stopAndCapture() and heap.capture(), which only stop or restart profiling and collect from V8, inside the synchronous collection. Labels are chosen at capture for the export format.
    • Visiting, which normalizes a profile, happens in the collection loop that yields to the event loop (perf(profiling): yield between collection and encoder starts #11325) between profiles: into a PprofProfileBuilder per profile, built as each profiler's pprofBuilderOptions tell, or into the cycle's one OtelProfilesBuilder, whose profiles share the request's dictionary. hasMissingSourceMaps comes from the visits.
    • The events profiler keeps its timeline samples as plain data and visits them too; its synthetic frame is named with a single space, which displays as blank like its former empty name.
    • In OTLP profiles, sample times are OTLP sample timestamps instead of end_timestamp_ns labels.
  • Vanilla OTLP: the profiles use semantic-convention attributes where there are some, and otherwise the execution context labels the eBPF host profiler also emits. There's no event.json and no top-level datadog.* attribute.
    • Resource: the attributes the other OTLP signals send (buildResourceAttributes), plus telemetry.sdk.{name,language,version} and the process's process.pid and process.runtime.{name,version}, which pprof uploads have as the process_id and runtime_version tags. telemetry.sdk.language=nodejs alone doesn't tell these apart from eBPF profiles of a Node.js process: those copy the resource of the process context that libdatadog publishes, which also has telemetry.sdk.language, but with telemetry.sdk.name=libdatadog. Attributes are converted as the other signals convert them, through a transformAttributes() now shared in opentelemetry/otlp/attributes.js.
    • Samples: carry the same labels as pprof samples. Thread name and ID are thread.name and thread.id (the worker's threadId). Labels without a semantic convention are sample attributes with the process.context.label. prefix, as the eBPF profiler emits thread context labels, and the backend already turns them into the usual pprof labels:
      • process.context.label.datadog.{os_thread_id,local_root_span_id,trace_endpoint,async_id} become os thread id, local root span id, trace endpoint and async id.
      • Custom labels are process.context.label.<key>. They're in the profiles, but not yet aggregated: the backend only aggregates allowlisted custom labels, and the upload doesn't carry an allowlist yet.
    • Sample types: CPU time and heap measures have the eBPF profiler's names (cpu-time/nanoseconds, heap-live-samples/count, heap-live-size/bytes, and alloc-samples/alloc-size in allocation mode), through the builder's renameSampleType option, so a measure has one name whichever profiler made it. Wall time, which the eBPF profiler doesn't have, is wall-time/nanoseconds, in the same style.
    • Links: a sample in a span links to it by trace ID and span ID. With code hotspots on, the wall profiler keeps the span's 128-bit trace ID in its profiling context.
    • Columns: only frames whose source map is declared but missing carry their column, as in pprof uploads, so the backend can tell the frames to unminify apart without an attribute.
  • Sending: OtlpProfilesExporter, on OtlpHttpExporterBase, sends OTLP-Profiles-Development-Version: 1.

Motivation

Part of emitting the OpenTelemetry profiles signal from the Node.js profiler. This is the minimal first version the team decided on, following the "OTLP Profiles SDK Decision Doc" (PROF space): no compression, only semantic-convention attributes, the span ID in a link. Selecting OTLP with OTEL_PROFILES_EXPORTER and the destination follow the PROF space's OTel SDK ADRs.

Additional Notes

  • Unreleased dependency: this needs the capture and builder APIs of @datadog/pprof from feat: add an OpenTelemetry profiles serializer pprof-nodejs#437, which aren't released yet. The OTLP profiler test fails in CI until they are and this depends on that release. Locally, it was tested against a linked pprof-nodejs checkout.
  • Not covered yet: timeline events aren't collected over OTLP (the events profiler is skipped in OTLP mode), near-OOM heap snapshots stay pprof-only, and requests are sent uncompressed and without retries.
  • Tests: tracer and profiling config, the OTLP and file exporters, collection cycles of both formats, the profilers' captures (labels per format: thread, span, endpoint, async ID and custom labels, trace IDs) and pprof builder options, the events profiler's timeline profile, and the link extractor. End to end, the smoke app's pprof (with timeline events) and OTLP uploads were both analyzed by prof-tester as family: node uploads.
  • End to end: with ddoghq/profiling-backend#9423, which recognizes these profiles by telemetry.sdk.name=datadog and telemetry.sdk.language=nodejs, prof-tester converted two 10 s cycles of a smoke app into family: node uploads and analyzed them, with CPU, wall and heap values in line with a pprof upload of the same app. (ddoghq/profiling-backend#9381 is the earlier design.)

@dd-octo-sts

dd-octo-sts Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 9.58 MB
Deduped: 10.33 MB
No deduping: 10.33 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.9 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Pipelines

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/apm-reliability/dd-trace-js | validate_supported_configurations_v2_local_file — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 71b808f | Docs | View more details | Give us feedback!

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.19355% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.06%. Comparing base (830b83d) to head (077b13d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ages/dd-trace/src/opentelemetry/otlp/attributes.js 65.11% 15 Missing ⚠️
...ce/src/opentelemetry/otlp/otlp_transformer_base.js 66.66% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (830b83d) and HEAD (077b13d). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (830b83d) HEAD (077b13d)
profiling 1 0
apm-integrations 1 0
apm-capabilities 1 0
test-optimization 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #11229       +/-   ##
===========================================
- Coverage   99.15%   81.06%   -18.09%     
===========================================
  Files        1136      951      -185     
  Lines      188287   158887    -29400     
  Branches       86       86               
===========================================
- Hits       186698   128809    -57889     
- Misses       1589    30078    +28489     
Flag Coverage Δ
ai-guard 63.31% <100.00%> (-0.01%) ⬇️
apm-capabilities ?
apm-integrations ?
appsec 59.22% <100.00%> (-0.01%) ⬇️
debugger 70.87% <74.19%> (-0.01%) ⬇️
instrumentation 60.16% <100.00%> (+0.05%) ⬆️
llmobs 82.50% <100.00%> (-0.01%) ⬇️
master-coverage 81.06% <74.19%> (?)
openfeature 68.04% <100.00%> (-0.02%) ⬇️
platform 68.14% <74.19%> (+0.01%) ⬆️
profiling ?
serverless 66.64% <74.19%> (+<0.01%) ⬆️
test-optimization ?

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

☔ View full report in Codecov by Harness.
📢 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.

@pr-commenter

pr-commenter Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-11-23 22:36:06

Comparing candidate commit 71b808f in PR branch attila/otlp-profiles with baseline commit 830b83d in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-20

  • unstable max_rss_usage [-52519.640KB; +51634.140KB] or [-25.543%; +25.112%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-26

  • unstable max_rss_usage [-58.381MB; +45.651MB] or [-19.487%; +15.238%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable max_rss_usage [-31.364MB; +21.952MB] or [-8.824%; +6.176%]

scenario:debugger-line-probe-with-snapshot-default-26

  • unstable max_rss_usage [-10041.757KB; +9024.757KB] or [-5.425%; +4.875%]

scenario:encoders-0.4-immediate-flush-20

  • unstable max_rss_usage [-2.427MB; +6.664MB] or [-2.850%; +7.826%]

scenario:openfeature-initialization-configuration-20

  • unstable max_rss_usage [-3.130MB; +9.055MB] or [-3.975%; +11.499%]

scenario:openfeature-initialization-configuration-26

  • unstable cpu_user_time [-133.024ms; +171.236ms] or [-7.696%; +9.906%]
  • unstable execution_time [-134.776ms; +169.374ms] or [-7.512%; +9.441%]
  • unstable throughput [-48176.066op/s; +37253.618op/s] or [-8.453%; +6.536%]

scenario:openfeature-initialization-error-20

  • unstable max_rss_usage [-4307.767KB; +3355.040KB] or [-5.778%; +4.500%]

scenario:openfeature-scale-full-24

  • unstable max_rss_usage [-22.975MB; +39.504MB] or [-8.634%; +14.846%]

scenario:openfeature-scale-full-26

  • unstable max_rss_usage [-33.540MB; +22.972MB] or [-16.004%; +10.962%]

scenario:plugin-graphql-long-with-depth-off-26

  • unstable cpu_user_time [-226.221ms; +488.243ms] or [-3.556%; +7.674%]
  • unstable execution_time [-240.350ms; +522.076ms] or [-3.712%; +8.062%]
  • unstable max_rss_usage [-22.168MB; +46.484MB] or [-11.398%; +23.901%]
  • unstable throughput [-24.954op/s; +11.381op/s] or [-7.141%; +3.257%]

scenario:plugin-graphql-long-with-depth-on-max-26

  • unstable max_rss_usage [-24.837MB; +39.144MB] or [-13.254%; +20.889%]

@szegedi
szegedi force-pushed the attila/otlp-profiles branch from f927632 to 83f8185 Compare November 17, 2026 13:38
…otlp

With OTEL_PROFILES_EXPORTER=otlp, the profiler sends each collection
cycle as one OTLP ExportProfilesServiceRequest to
OTEL_EXPORTER_OTLP_PROFILES_ENDPOINT, in place of the agent destination
of DD_PROFILING_EXPORTERS. The endpoint defaults like the other OTLP
signals', with the profiles signal's /v1development/profiles path, and
the agentless intake in agentless mode. OTEL_PROFILES_EXPORTER=none
disables profiling unless DD_PROFILING_ENABLED is set.

The wall and space profilers pass their profiles to an
OtelProfilesBuilder of @datadog/pprof instead of serializing pprof, so
all of a cycle's profiles share the request's dictionary. The profiles
are vanilla OTLP, with only semantic-convention attributes:
- The resource is the other OTLP signals', from buildResourceAttributes,
  with telemetry.sdk.{name,language,version}. Its attributes are
  converted as the other signals convert them, now through a shared
  transformAttributes() in opentelemetry/otlp/attributes.js.
- Samples carry thread.name and thread.id; other labels, which have no
  semantic convention, are left out. Sample times are sample
  timestamps.
- A sample in a span links to it by trace ID and span ID. With code
  hotspots on, the wall profiler keeps the span's 128-bit trace ID in
  its profiling context for that.
- Only frames whose source map is declared but missing carry their
  column, as in pprof uploads, so the backend can tell the frames to
  unminify apart.

The file exporter also writes the request. Timeline events are not
collected over OTLP yet, and near-OOM heap snapshots stay pprof-only.
Requests are sent uncompressed.

This needs the visitor APIs of @datadog/pprof (pprof-nodejs #437), which
are not released yet.
@szegedi
szegedi force-pushed the attila/otlp-profiles branch from 83f8185 to 9035211 Compare November 19, 2026 16:08
The OS thread ID has no semantic convention, so send it as the Datadog
execution context label process.context.label.datadog.os_thread_id,
which the backend turns into the "os thread id" pprof label.
Send the local root span ID, trace endpoint and async ID as Datadog
execution context labels (process.context.label.datadog.*), and custom
labels as execution context labels under their own keys
(process.context.label.<key>), so OTLP samples carry the same labels as
pprof ones. Custom labels aren't allowlisted for aggregation yet, but
they are in the profiles.
OTLP profiles name CPU time and heap measures as the eBPF host profiler
does (cpu-time, heap-live-samples, heap-live-size, alloc-samples,
alloc-size), so a measure has one name whichever profiler made it. Wall
time has no eBPF counterpart and keeps its name.
In the style of the eBPF profiler's cpu-time, which OTLP CPU time
profiles now use.
process.pid, process.runtime.name and process.runtime.version, the
semantic-convention attributes of what pprof uploads have as the
process_id and runtime_version tags.

@szegedi szegedi left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

First-pass review meant to be fed back to the agent.

Comment thread packages/dd-trace/src/config/index.js Resolved
Comment on lines +459 to +461
const profile = otlpBuilder === undefined
? profiler.profile(restart, startDate, endDate)
: profiler.visit(restart, otlpBuilder.visitor())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't we want to symmetrically use either a PprofBuilder or an OtlpBuilder instead of calling different methods? I guess the current choice allows us to defer rewriting the EventProfiler to visitor. Also, why does profiler.visit not need startDate and endDate?

const profile = profiler.profile(restart, startDate, endDate)
const profile = otlpBuilder === undefined
? profiler.profile(restart, startDate, endDate)
: profiler.visit(restart, otlpBuilder.visitor())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it wouldn't be the most efficient to do as little work as possible in the synchronous restart path. See the improvements we made in #11325. It almost feels to me like various profiler.profile methods could only produce raw pprof-nodejs TimeProfile, AllocationProfileNode/AllocationProfileNodeWithStats objects (the ones that are then used as the input to the normalizer) and even the normalization can be deferred until profile.encode. Especially with the #11325 the more we can do in the per-profile loop that yeilds to the event loop, the better. I also feel like this method is becoming a bit of a spaghetti with pprof and otlp concerns interleaved. I feel there should be a better unification refactoring here.

Comment thread packages/dd-trace/src/config/index.js Resolved
- Only default the OTLP profiles endpoint, and add the API key header,
  with OTEL_PROFILES_EXPORTER=otlp.
- Get a sample context's profiling context and custom labels without
  allocating an array for every sample.
- Reword and drop comments.
Instead of converting every span's trace ID to a bigint through hex when
its profiling context is made, keep the span context's trace identifier
and the hex of the upper 64 bits, and combine them when a sample of the
span needs its link, once per span. The lower 64 bits come from the
identifier's cached bigint, like span IDs. Links are cached by span ID
alone, without building a string key for every sample.
# Conflicts:
#	packages/dd-trace/src/profiling/profilers/wall.js
#	packages/dd-trace/test/profiling/profiler.spec.js
Profilers capture their profiles, and the profiler visits them once the
synchronous collection is done, into either a pprof or the OTLP builder,
so the two formats differ only in the visitor:

- capture() replaces profile(), visit() and encode(). The wall and space
  profilers use @datadog/pprof's time.stopAndCapture() and heap.capture(),
  which only stop or restart profiling and collect from V8. Labels are
  chosen at capture for the format the profiles are exported in.
- pprofBuilderOptions tell how a profiler's pprof is built: the wall
  profiler's low-cardinality labels and emitted columns, the space
  profiler's packed columns, the events profiler's timestamp label.
- Visiting, which normalizes a profile, now happens in the loop that
  yields to the event loop between profiles, rather than in the
  synchronous collection. hasMissingSourceMaps comes from the visits.
- The events profiler keeps timeline samples as plain data, and its
  captured profile visits them. Its synthetic frame is named with a single
  space, which displays as blank like the empty name it had, as visitors
  give frames without a name a placeholder.

This branch has not been deployed

No deployments
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.

1 participant