sdk/profile: Add design doc #9560
<!-- pull-request-dashboard-status -->
<!-- pull-request-dashboard-status-revision:25 -->
<!-- pull-request-dashboard-author-nudge-episode:3037337ad4c94d13b689189e346a7116 -->
Pull request dashboard status
Waiting on the author · refreshed 2026-12-03 09:10 UTC
Respond to 4 review items (e.g. link a commit, explain why not, ask a follow-up):
<details>
<summary>Status above doesn't look right?</summary>
<br>
/dashboard route:reviewers to route it to them.</details>
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 90.1%. Comparing base (
4d719c2) to head (823fc45).<details><summary>Additional details and impacted files</summary>

@@ Coverage Diff @@
## main #9560 +/- ##
=====================================
Coverage 90.1% 90.1%
=====================================
Files 360 360
Lines 24776 24776
=====================================
+ Hits 22326 22328 +2
+ Misses 2450 2448 -2
see 8 files with indirect coverage changes
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
Is that preferred? With so many options a single RuntimeProducerOption struct would be enough 🤷🏽
Do we want fgprof as well? https://github.com/felixge/fgprof
It is apparently useful, but honestly I never found it useful myself (tried 2 times) -- maybe I didn't have good workload for this
I think this should be good to 👍🏽
cc @dashpole @pellared
With a shared RuntimeProducer, each Produce call advances its delta baselines and rotates its CPU window, so an on-demand diagnostic collection consumes data the next OTLP export would otherwise receive. Serializing calls does not give readers independent intervals. Specify per-reader delta state, delivery of the same collected batch to every reader, or an explicit restriction on sharing stateful producers before recommending this setup.
The rollout omits the PRs that now contain the runtime implementation: #9545's updated description places the pprof decoder/converter in #9558 and RuntimeProducer in #9559. Include both in phase 2 and the prototype-stack list at sdk/profile/DESIGN.md:9–11 so maintainers can follow the full implementation split.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The design recommends sharing a stateful RuntimeProducer without preventing diagnostic reads from consuming data intended for OTLP exports, and its rollout omits implementation PRs #9558 and #9559.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds a design document for the experimental Go Profiles SDK, supporting design consensus for #8449 before the implementation stack is reviewed. This PR changes documentation only.
Changes:
| File | Description |
| ---- | ----------- |
| sdk/profile/DESIGN.md | Documents the proposed Profiles SDK architecture, behavior, and implementation roadmap. |
</details>
<sub>Review effort: Balanced</sub>
As also pointed out in https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496, some Go profiles are not distinguishable. Maybe start with distinguishable profiles only in the first step.
addressed in 989735d27: added #9558 and #9559 to the prototype stack, phase 2 rollout, and benchmark references.
addressed in 7cb41d2f6: documented that stateful delta or CPU producers must not be shared across independent readers and should attach per reader or fan out at the Exporter layer.
addressed in 320f9c2b2: scoped initial v0.0.0 RuntimeProducer to distinguishable profiles (heap, allocs, goroutine, opt-in cpu) and deferred mutex and block profiles to phase 3 until the spec defines how to distinguish them.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
As the OTel Profiles signal is still in Alpha and not declared stable, should the proposed module path reflect that?
In OTel collector components handling profiling related data are prefixed with x. E.g. xconsumer for concumser or xreceiver for receiver. Showing that something is not stable yet is important I think as there still can be breaking changes.
These are separate modules versions v0.x.y and this is not needed. Such things would be only needed if we would like to add experimental features to stable modules.
The SDK inherits third-party dependencies through sdk/resource, which imports github.com/google/uuid (sdk/resource/builtin.go:12), so this guarantee is too strong. Describe the goal as a protobuf-free SDK with no additional third-party dependencies beyond those inherited from existing OpenTelemetry modules. Apply the same clarification at sdk/profile/DESIGN.md:231: the internal decoder avoids an additional pprof dependency, not all third-party dependencies.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The design document overstates dependency guarantees: the SDK inherits third-party dependencies through sdk/resource, and the internal decoder avoids only an additional pprof dependency.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
Following up on #discussion_r4652148885, this diagram still shows a single RuntimeProducer feeding ProfilerProvider and fanning out to both PeriodicReader and ManualReader, which contradicts the non-sharing rule below. It should show RuntimeProducer attached per reader (or a single reader with exporter-level fan-out).
I would make WithProducer a reader-only option like sdk/metric.WithProducer instead of also accepting it on ProfilerProvider. Since RuntimeProducer is stateful by default, attaching producers only to readers prevents cross-reader delta and CPU window corruption by construction rather than relying on a doc warning.
pprof.Lookup("goroutine") triggers two brief STW pauses and walks all live goroutines, which can add noticeable latency and allocation overhead on services with many goroutines. It would be worth noting that cost here instead of listing "None" since goroutine profiling is enabled by default.
Are otel.trace_id and otel.span_id agreed on in the Profiling SIG, or should those pprof label keys be aligned upstream first (for example grafana/otel-profiling-go uses trace_id and span_id)? Calling this out under Open questions or upstream spec items would help avoid diverging before trace correlation lands.
sdk/metric.Reader actually omits ForceFlush (removed in #4375) and MeterProvider type-asserts interface{ ForceFlush(context.Context) error } instead so pull readers like ManualReader do not have to expose a no-op method. I would follow that same pattern here and keep ForceFlush off Reader and ManualReader.
I would wait until OTEL_PROFILES_EXPORT_INTERVAL and OTEL_PROFILES_EXPORT_TIMEOUT are formalized upstream before reading them by default.
A sdk/trace.SpanProcessor cannot propagate pprof.WithLabels out of Tracer.Start (since OnStart returns nothing) and OnEnd has no context.Context and may run on another goroutine, so this needs a trace.TracerProvider wrapper (like otel-profiling-go) instead. That wrapper only depends on go.opentelemetry.io/otel/trace, which sdk/profile already imports for profiledata.Link, so it would not add a sdk/trace dependency.
I like having internal/observ right from the start as long as it is gated behind OTEL_GO_X_OBSERVABILITY like the other OTLP exporters.
I prefer keeping the sealed RuntimeProducerOption interface to match CONTRIBUTING.md#configuration and avoid zero-value bool ambiguity for default-enabled profiles. You can also cut the option count by dropping WithHeapProfile, WithAllocsProfile, and WithGoroutineProfile since those three are on by default and CONTRIBUTING.md only defines Without* for default-true bool options.
I would leave fgprof out of sdk/profile. Polling runtime.GoroutineProfile at 99 Hz has noticeable STW and stack-walk overhead at high goroutine counts, and callers who want wall-clock profiling can wire it in as a custom Producer or contrib module.
addressed in cf2493161: clarified that sdk/profile avoids protobuf and additional third-party dependencies beyond inherited OpenTelemetry modules, and that the internal decoder avoids adding a github.com/google/pprof dependency.
addressed in 5766041a9: made WithProducer a reader-only ReaderOption matching sdk/metric.WithProducer and removed provider-level producer registration.
addressed in d51708882: updated the pipeline diagram to attach separate RuntimeProducer instances per reader instead of sharing one through ProfilerProvider.
addressed in 6a5653888: kept the sealed RuntimeProducerOption interface and dropped WithHeapProfile, WithAllocsProfile, and WithGoroutineProfile to match CONTRIBUTING.md#configuration.
addressed in bee6d47d4: documented the two brief STW pauses and live-goroutine stack walk cost for goroutine profiling in the RuntimeProducer table.
addressed in 4479f83af: removed ForceFlush from Reader and ManualReader and documented ProfilerProvider type-asserting interface{ ForceFlush(context.Context) error } to match sdk/metric.Reader.
addressed in 944cd7456: added pprof trace/span label key alignment (otel.trace_id/otel.span_id vs. trace_id/span_id) to Open questions and Phase 4 upstream spec items.
addressed in 5c1d95200: documented waiting until OTEL_PROFILES_EXPORT_INTERVAL and OTEL_PROFILES_EXPORT_TIMEOUT are formalized upstream before reading them by default and closed the open question.
addressed in ee4326b34: updated trace-context correlation to use a trace.TracerProvider wrapper (depending only on go.opentelemetry.io/otel/trace) instead of sdk/trace.SpanProcessor and closed the open question.
Thanks for the detailed review, what could be the next steps?
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The design still needs to document same-goroutine, properly nested label restoration and distinguish mutex-rate restoration from block-profile rate ownership and reset behavior.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<details>
<summary><strong>1 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
The design proposal leaves goroutine-label restoration unsafe across cross-goroutine, repeated, or out-of-order span endings without documenting scope restrictions or using an explicit scoped API.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🟢 Approval recommended
The documentation-only Profiles SDK design proposal has no active review issues.
No open issues 🎉
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
Thanks for this PR!
Follow-up review of the Profiles SDK design.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The documentation should clarify that direct PeriodicReader.Collect calls consume intervals without exporting them and recommend ForceFlush for immediate export.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
The reader contract needs to document that direct Collect consumes interval data without exporting it and direct callers to ForceFlush when immediate export is intended.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
I think we can close this and move the discussion upstream: https://github.com/open-telemetry/opentelemetry-specification/pull/5476
@bwplotka, can we reopen this? Even with OTEP and OTel Spec we still want to have this design doc to have some history and clear agreements around design decisions. E.g. see https://github.com/open-telemetry/opentelemetry-go/commits/main/log/DESIGN.md
Seems like https://github.com/open-telemetry/opentelemetry-go/pull/9560#discussion_r4711669272 and https://github.com/open-telemetry/opentelemetry-go/pull/9560#discussion_r4711163830 (duplicated threads) are still not addressed.
I plan to approve the PR when these threads are resolved.
@pellared: Seems like https://github.com/open-telemetry/opentelemetry-go/pull/9560#discussion_r4711669272 and https://github.com/open-telemetry/opentelemetry-go/pull/9560#discussion_r4711163830 (duplicated threads) are still not addressed.
addressed in 20e7d0fcb: documented that direct PeriodicReader.Collect consumes stateful producer intervals without exporting them and recommended ForceFlush for immediate export. Also addressed the follow-up threads from @dashpole and @dmathieu in the latest commits.
LGTM, but let's land the OTEP first.
<!-- pull-request-dashboard-author-nudge:3037337ad4c94d13b689189e346a7116 -->
Hi @bwplotka — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.
/dashboard route:reviewers.
bwplotka
Part of #8449. Follows up on the review discussion in #9546 to give maintainers a compact design doc for the experimental Profiles SDK before reviewing the full implementation stack (#9545, #9546, #9547).
Documents the module structure (
sdk/profile,sdk/profile/profiledata,otlpprofilehttp,otlpprofilegrpc), pull-basedProfilerProvider/Producer/Reader/ExporterAPI, default-safeRuntimeProducerbehavior, OTLP transform invariants, trace-context correlation options, a comparison with OpenTelemetry .NET'sContinuousProfilerfor upstream OTel spec/OTEP alignment, phased rollout plan, open questions, and rejected alternatives.Related OTEP: https://github.com/open-telemetry/opentelemetry-specification/pull/5476