Repository navigation
Conversation
Overall package sizeSelf size: 9.58 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 |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 1 Pipeline job failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 71b808f | Docs | View more details | Give us feedback! |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-11-23 22:36:06 Comparing candidate commit 71b808f in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2470 metrics, 17 unstable metrics.
|
f927632 to
83f8185
Compare
…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.
83f8185 to
9035211
Compare
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
left a comment
There was a problem hiding this comment.
First-pass review meant to be fed back to the agent.
| const profile = otlpBuilder === undefined | ||
| ? profiler.profile(restart, startDate, endDate) | ||
| : profiler.visit(restart, otlpBuilder.visitor()) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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.
- 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.
What does this PR do?
Adds OTLP export of profiles. With
OTEL_PROFILES_EXPORTER=otlp, the profiler sends each collection cycle as one OTLPExportProfilesServiceRequesttoOTEL_EXPORTER_OTLP_PROFILES_ENDPOINT, in place of the agent destination.DD_PROFILING_EXPORTERSkeeps choosing destinations;filealso writes the request.OTEL_PROFILES_EXPORTER(none|otlp).nonedisables profiling unlessDD_PROFILING_ENABLEDis set, asOTEL_TRACES_EXPORTER=nonedoes for tracing.OTEL_EXPORTER_OTLP_PROFILES_{ENDPOINT,HEADERS,PROTOCOL,TIMEOUT}, which fall back to the genericOTEL_EXPORTER_OTLP_*. The protocol ishttp/protobufonly./v1development/profilespath, or the agentlessotlp.<site>intake with the API key.capture()replaces the profilers'profile()andencode(). The wall and space profilers use @datadog/pprof'stime.stopAndCapture()andheap.capture(), which only stop or restart profiling and collect from V8, inside the synchronous collection. Labels are chosen at capture for the export format.PprofProfileBuilderper profile, built as each profiler'spprofBuilderOptionstell, or into the cycle's oneOtelProfilesBuilder, whose profiles share the request's dictionary.hasMissingSourceMapscomes from the visits.end_timestamp_nslabels.event.jsonand no top-leveldatadog.*attribute.buildResourceAttributes), plustelemetry.sdk.{name,language,version}and the process'sprocess.pidandprocess.runtime.{name,version}, which pprof uploads have as theprocess_idandruntime_versiontags.telemetry.sdk.language=nodejsalone 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 hastelemetry.sdk.language, but withtelemetry.sdk.name=libdatadog. Attributes are converted as the other signals convert them, through atransformAttributes()now shared inopentelemetry/otlp/attributes.js.thread.nameandthread.id(the worker'sthreadId). Labels without a semantic convention are sample attributes with theprocess.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}becomeos thread id,local root span id,trace endpointandasync id.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.cpu-time/nanoseconds,heap-live-samples/count,heap-live-size/bytes, andalloc-samples/alloc-sizein allocation mode), through the builder'srenameSampleTypeoption, so a measure has one name whichever profiler made it. Wall time, which the eBPF profiler doesn't have, iswall-time/nanoseconds, in the same style.OtlpProfilesExporter, onOtlpHttpExporterBase, sendsOTLP-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_EXPORTERand the destination follow the PROF space's OTel SDK ADRs.Additional Notes
family: nodeuploads.telemetry.sdk.name=datadogandtelemetry.sdk.language=nodejs, prof-tester converted two 10 s cycles of a smoke app intofamily: nodeuploads 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.)