← Back to Pull requests

sdk/profile: Add design doc #9560

Open
bwplotka opened this pull request with 242 lines diff across 1 files
View on GitHub
bwplotka bwplotka commented on Nov 20, 2026 14:33 UTC
Author

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-based ProfilerProvider / Producer / Reader / Exporter API, default-safe RuntimeProducer behavior, OTLP transform invariants, trace-context correlation options, a comparison with OpenTelemetry .NET's ContinuousProfiler for upstream OTel spec/OTEP alignment, phased rollout plan, open questions, and rejected alternatives.

Related OTEP: https://github.com/open-telemetry/opentelemetry-specification/pull/5476

Diff: 242 lines (+242 / -0) across 1 files Reviewer: bwplotka Review duration: 19263m
All Vouch review confidence checks passed
Residual risk 0.08 = Change Risk (0.50) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 242 lines diff across 1 files
0.50
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 5 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
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.329
Self Review self_review
0.140
Real PR Conversation Timeline
52 items
opentelemetry-pr-dashboard[bot] opentelemetry-pr-dashboard[bot] commented on Nov 20, 2026 14:33 UTC
Bot

<!-- 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):

  • Inline threads: 1, 2, 3, 4
  • <details>
    <summary>Status above doesn't look right?</summary>

    <br>

  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.

  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.

  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.
  • </details>

    codecov[bot] codecov[bot] commented on Nov 20, 2026 14:36 UTC
    Bot

    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>

    ![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-go/pull/9560?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)

    @@          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>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    bwplotka bwplotka commented on code on Nov 21, 2026 10:58 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption

    Is that preferred? With so many options a single RuntimeProducerOption struct would be enough 🤷🏽

    bwplotka bwplotka commented on code on Nov 21, 2026 10:59 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |

    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

    bwplotka bwplotka commented on Nov 21, 2026 11:00 UTC
    Reviewer

    I think this should be good to 👍🏽

    bwplotka bwplotka commented on Nov 21, 2026 11:02 UTC
    Author

    cc @dashpole @pellared

    Copilot Copilot commented on code on Nov 21, 2026 11:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +- Global mutex and block profiling rate updates are reference-counted across `RuntimeProducer` instances so shutting down one instance does not prematurely disable profiling for another.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `mutex` fraction, `block` rate, `cpu`, delta flag | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) and [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?
    +- Should in-process trace-context correlation live as a `sdk/trace.SpanProcessor` / wrapper in `sdk/profile` (adding a dependency from `sdk/profile` on `sdk/trace`) or in a separate bridge package?
    +- Should `otlpprofilehttp` and `otlpprofilegrpc` add self-observability metrics (`internal/observ`) in `v0.0.0`, or wait for profiling exporter semantic conventions?
    +
    +## Rejected alternatives
    +
    +### Create a `go.opentelemetry.io/otel/profile` API module upfront
    +
    +Traces, metrics, and logs require a lightweight API module because instrumented libraries call them directly on request hot paths. Continuous profiling is runtime- and SDK-driven, with no upstream Profiles API specification yet. Starting with `sdk/profile` avoids stabilizing an API package without real instrumentation callers; if an API emerges later, `ProfilerProvider` can implement it cleanly.
    +
    +### Use `Processor` (push model, like `sdk/log`) instead of `Reader` and `Producer` (pull model, like `sdk/metric`)
    +
    +Go runtime profiles are collected on a schedule and converted in batches rather than emitted event-by-event. The pull-based `ProfilerProvider` + `Producer` + `Reader` + `Exporter` pattern from `sdk/metric` fits this lifecycle directly and allows multiple readers (such as OTLP export alongside an on-demand diagnostic reader) to share a single `ProfilerProvider`.

    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.

    Copilot Copilot commented on code on Nov 21, 2026 11:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +- Global mutex and block profiling rate updates are reference-counted across `RuntimeProducer` instances so shutting down one instance does not prematurely disable profiling for another.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `mutex` fraction, `block` rate, `cpu`, delta flag | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.

    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.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 21, 2026 11:06 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Prevent shared producer collections from consuming export data · New

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Include PRs #9558 and #9559 in the rollout · New

  • </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:

  • Describes the proposed module layout, profile data model, pull-based pipeline, and runtime profiling defaults.

  • Defines OTLP transform invariants, transport behavior, and trace-correlation options.

  • Compares cross-language approaches and outlines rollout phases, open questions, and rejected alternatives.
  • | File | Description |
    | ---- | ----------- |
    | sdk/​profile/​DESIGN.md | Documents the proposed Profiles SDK architecture, behavior, and implementation roadmap. |
    </details>

    <sub>Review effort: Balanced</sub>

    florianl florianl commented on code on Nov 23, 2026 08:20 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption

    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.

    bwplotka bwplotka commented on code on Nov 23, 2026 08:51 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +- Global mutex and block profiling rate updates are reference-counted across `RuntimeProducer` instances so shutting down one instance does not prematurely disable profiling for another.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `mutex` fraction, `block` rate, `cpu`, delta flag | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.

    addressed in 989735d27: added #9558 and #9559 to the prototype stack, phase 2 rollout, and benchmark references.

    bwplotka bwplotka commented on code on Nov 23, 2026 08:51 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +- Global mutex and block profiling rate updates are reference-counted across `RuntimeProducer` instances so shutting down one instance does not prematurely disable profiling for another.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `mutex` fraction, `block` rate, `cpu`, delta flag | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) and [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?
    +- Should in-process trace-context correlation live as a `sdk/trace.SpanProcessor` / wrapper in `sdk/profile` (adding a dependency from `sdk/profile` on `sdk/trace`) or in a separate bridge package?
    +- Should `otlpprofilehttp` and `otlpprofilegrpc` add self-observability metrics (`internal/observ`) in `v0.0.0`, or wait for profiling exporter semantic conventions?
    +
    +## Rejected alternatives
    +
    +### Create a `go.opentelemetry.io/otel/profile` API module upfront
    +
    +Traces, metrics, and logs require a lightweight API module because instrumented libraries call them directly on request hot paths. Continuous profiling is runtime- and SDK-driven, with no upstream Profiles API specification yet. Starting with `sdk/profile` avoids stabilizing an API package without real instrumentation callers; if an API emerges later, `ProfilerProvider` can implement it cleanly.
    +
    +### Use `Processor` (push model, like `sdk/log`) instead of `Reader` and `Producer` (pull model, like `sdk/metric`)
    +
    +Go runtime profiles are collected on a schedule and converted in batches rather than emitted event-by-event. The pull-based `ProfilerProvider` + `Producer` + `Reader` + `Exporter` pattern from `sdk/metric` fits this lifecycle directly and allows multiple readers (such as OTLP export alongside an on-demand diagnostic reader) to share a single `ProfilerProvider`.

    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.

    bwplotka bwplotka commented on code on Nov 23, 2026 08:51 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption

    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-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 23, 2026 08:52 UTC
    Reviewer

    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.

    florianl florianl commented on code on Nov 23, 2026 14:17 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.

    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.

    pellared pellared commented on code on Nov 23, 2026 14:19 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.

    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.

    Copilot Copilot commented on code on Nov 24, 2026 23:02 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.

    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.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 24, 2026 23:02 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Clarify SDK dependencies are inherited, not absent · New

  • </details>

    <details>
    <summary><strong>2 resolved since last review</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Prevent shared producer collections from consuming export data

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Include PRs #9558 and #9559 in the rollout

  • </details>

    <sub>Review effort: Balanced</sub>

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]

    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).

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `cpu`, delta flag (deferred: `mutex`, `block`) | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile` core and `profiledata`), [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558) (`sdk/profile/internal/pprof`), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559) (`RuntimeProducer`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in `mutex` and `block` profiles (with reference-counted rate restoration) once the upstream spec settles distinguishing profiles with identical `sample_type` values, opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?

    I would wait until OTEL_PROFILES_EXPORT_INTERVAL and OTEL_PROFILES_EXPORT_TIMEOUT are formalized upstream before reading them by default.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `cpu`, delta flag (deferred: `mutex`, `block`) | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile` core and `profiledata`), [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558) (`sdk/profile/internal/pprof`), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559) (`RuntimeProducer`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in `mutex` and `block` profiles (with reference-counted rate restoration) once the upstream spec settles distinguishing profiles with identical `sample_type` values, opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?
    +- Should in-process trace-context correlation live as a `sdk/trace.SpanProcessor` / wrapper in `sdk/profile` (adding a dependency from `sdk/profile` on `sdk/trace`) or in a separate bridge package?

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `cpu`, delta flag (deferred: `mutex`, `block`) | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile` core and `profiledata`), [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558) (`sdk/profile/internal/pprof`), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559) (`RuntimeProducer`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in `mutex` and `block` profiles (with reference-counted rate restoration) once the upstream spec settles distinguishing profiles with identical `sample_type` values, opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?
    +- Should in-process trace-context correlation live as a `sdk/trace.SpanProcessor` / wrapper in `sdk/profile` (adding a dependency from `sdk/profile` on `sdk/trace`) or in a separate bridge package?
    +- Should `otlpprofilehttp` and `otlpprofilegrpc` add self-observability metrics (`internal/observ`) in `v0.0.0`, or wait for profiling exporter semantic conventions?

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:06 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption

    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.

    dashpole dashpole commented on code on Nov 25, 2026 21:07 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithMutexProfile() RuntimeProducerOption
    +func WithMutexProfileFraction(fraction int) RuntimeProducerOption
    +func WithBlockProfile() RuntimeProducerOption
    +func WithBlockProfileRate(rate int) RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| Mutex contention | Opt-in (`WithMutexProfile` / `WithMutexProfileFraction`) | Interval delta | `.../runtime/mutex` | Refcounted `runtime.SetMutexProfileFraction`, restored on `Shutdown` |
    +| Blocking | Opt-in (`WithBlockProfile` / `WithBlockProfileRate`) | Interval delta | `.../runtime/block` | Refcounted `runtime.SetBlockProfileRate`, reset on `Shutdown` |
    +| CPU | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |

    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.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.

    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.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.

    addressed in 5766041a9: made WithProducer a reader-only ReaderOption matching sdk/metric.WithProducer and removed provider-level producer registration.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]

    addressed in d51708882: updated the pipeline diagram to attach separate RuntimeProducer instances per reader instead of sharing one through ProfilerProvider.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,240 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ProfilerProvider`, `ManualReader`, and `PeriodicReader`, matching `sdk/metric.WithProducer`.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption

    addressed in 6a5653888: kept the sealed RuntimeProducerOption interface and dropped WithHeapProfile, WithAllocsProfile, and WithGoroutineProfile to match CONTRIBUTING.md#configuration.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |

    addressed in bee6d47d4: documented the two brief STW pauses and live-goroutine stack walk cost for goroutine profiling in the RuntimeProducer table.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:

    addressed in 4479f83af: removed ForceFlush from Reader and ManualReader and documented ProfilerProvider type-asserting interface{ ForceFlush(context.Context) error } to match sdk/metric.Reader.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.

    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.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `cpu`, delta flag (deferred: `mutex`, `block`) | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile` core and `profiledata`), [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558) (`sdk/profile/internal/pprof`), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559) (`RuntimeProducer`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in `mutex` and `block` profiles (with reference-counted rate restoration) once the upstream spec settles distinguishing profiles with identical `sample_type` values, opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?

    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.

    bwplotka bwplotka commented on code on Nov 26, 2026 07:44 UTC
    Code Review
    sdk/profile/DESIGN.md:1
    @@ -0,0 +1,239 @@
    +# Profiles SDK
    +
    +## Abstract
    +
    +`go.opentelemetry.io/otel/sdk/profile` provides an experimental Go Profiles SDK and built-in Go runtime profiler targeting the Alpha [OpenTelemetry Profiles specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/README.md) (`v1development`).
    +
    +This design is part of [#8449](https://github.com/open-telemetry/opentelemetry-go/issues/8449). The prototype stack lives in:
    +
    +- [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545): core `go.opentelemetry.io/otel/sdk/profile` and `go.opentelemetry.io/otel/sdk/profile/profiledata`
    +- [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558): `sdk/profile/internal/pprof` decoder, delta subtraction, build IDs, and converter
    +- [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559): `sdk/profile` `RuntimeProducer`
    +- [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547): `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +
    +## Background
    +
    +Out-of-process eBPF profilers such as [opentelemetry-ebpf-profiler](https://github.com/open-telemetry/opentelemetry-ebpf-profiler) collect low-overhead CPU profiles across hosts without code changes, but cannot capture Go runtime profiles cheaply: live heap (`inuse_space`, `inuse_objects`), allocation rates (`alloc_space`, `alloc_objects`), goroutine stacks, mutex contention, and blocking profiles.
    +
    +The Go Profiles SDK fills that gap with four design goals:
    +
    +- Collect live heap, interval-delta allocations, and goroutine snapshots by default without mutating global Go runtime profiling rates or claiming the single process-wide CPU profiler.
    +- Keep `go.opentelemetry.io/otel/sdk/profile` free of protobuf and third-party dependencies, and keep `otlpprofilehttp` free of `google.golang.org/grpc` by using `go.opentelemetry.io/proto/slim/otlp`.
    +- Reuse the pull-oriented `Provider`, `Producer`, `Reader`, and `Exporter` architecture from `go.opentelemetry.io/otel/sdk/metric`, sealed `Option` interfaces, and existing OTLP exporter patterns.
    +- Emit deduplicated, orphan-free `ProfilesDictionary` payloads that pass [sig-profiling/profcheck](https://github.com/open-telemetry/sig-profiling/tree/main/profcheck).
    +
    +## Module structure
    +
    +Modules use singular `profile` to match `sdk/trace`, `sdk/metric`, `sdk/log`, and `exporters/otlp/otlp{trace,metric,log}`. All profiling modules start in the `v0.0.0` experimental module set in `versions.yaml`.
    +
    +SDK module:
    +
    +- `go.opentelemetry.io/otel/sdk/profile`: `ProfilerProvider`, `Producer`, `RuntimeProducer`, `Reader`, `ManualReader`, `PeriodicReader`, `Exporter`
    +- `go.opentelemetry.io/otel/sdk/profile/profiledata`: protobuf-free SDK profile data model
    +
    +Exporter modules:
    +
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilehttp`
    +- `go.opentelemetry.io/otel/exporters/otlp/otlpprofile/otlpprofilegrpc`
    +- Future: `go.opentelemetry.io/otel/exporters/stdout/stdoutprofile`
    +
    +## Pipeline architecture
    +
    +```mermaid
    +flowchart LR
    +    RP["RuntimeProducer (runtime/pprof)"] --> PP["ProfilerProvider (+ Resource)"]
    +    CP["Custom Producer"] --> PP
    +    PP --> PR["PeriodicReader (interval / timeout)"]
    +    PP --> MR["ManualReader (Collect)"]
    +    PR --> EXP["Exporter"]
    +    EXP --> HTTP["otlpprofilehttp (proto/slim/otlp)"]
    +    EXP --> GRPC["otlpprofilegrpc (proto/otlp)"]
    +    HTTP --> RCV["OTLP Receiver (/v1development/profiles)"]
    +    GRPC --> RCV
    +```
    +
    +## Data model (`profiledata`)
    +
    +`go.opentelemetry.io/otel/sdk/profile/profiledata` mirrors the OTLP Profiles `v1development` hierarchy without exposing protobuf generated types in the SDK API:
    +
    +- `ResourceProfiles` holds `*resource.Resource` and `[]ScopeProfiles`.
    +- `ScopeProfiles` holds `instrumentation.Scope` and `[]Profile`.
    +- `Profile` holds `SampleType`, `Samples`, `Time`, `Duration`, `PeriodType`, `Period`, `ProfileID`, `DroppedAttributesCount`, `OriginalPayloadFormat`, `OriginalPayload`, and `Attributes`.
    +- `Sample` holds `Stack []*Location`, `Values []int64`, `Timestamps []time.Time`, `Attributes []Attribute`, and `Link`.
    +- `Location`, `Mapping`, `Line`, `Function`, `ValueType`, `Link` (`trace.TraceID`, `trace.SpanID`), and `Attribute` (`attribute.Key`, `attribute.Value`, optional UCUM `Unit`).
    +
    +`profiledata.Attribute` reuses `go.opentelemetry.io/otel/attribute` for keys and structured `attribute.Value` (matching `go.opentelemetry.io/otel/sdk/log`) while adding the optional UCUM `Unit` field required by OTLP `KeyValueAndUnit`. `Location` and `Mapping` are shared pointers within a batch so exporters can cache dictionary indices by pointer identity before falling back to content deduplication.
    +
    +## ProfilerProvider
    +
    +`ProfilerProvider` coordinates a single `*resource.Resource` (defaulting to `resource.Default()`), registered `Producer` instances, and registered `Reader` instances:
    +
    +```go
    +type ProfilerProvider struct { /* ... */ }
    +
    +func NewProfilerProvider(options ...Option) *ProfilerProvider
    +func (*ProfilerProvider) ForceFlush(ctx context.Context) error
    +func (*ProfilerProvider) Shutdown(ctx context.Context) error
    +
    +type Option interface { /* unexported */ }
    +func WithResource(res *resource.Resource) Option
    +func WithReader(r Reader) Option
    +func WithProducer(p Producer) ProducerOption
    +```
    +
    +`Shutdown` is idempotent (`sync.Once`). It shuts down readers first so their final collection and export can read from provider-level producers, then shuts down producers implementing `Shutdown(context.Context) error`.
    +
    +## Producer and RuntimeProducer
    +
    +`Producer` is the single-method extension point for profile sources:
    +
    +```go
    +type Producer interface {
    +	Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +}
    +```
    +
    +Producers that hold runtime state may also implement `Shutdown(context.Context) error`, which `ProfilerProvider` and readers invoke during shutdown. `WithProducer(p)` returns a `ProducerOption` accepted by `ManualReader` and `PeriodicReader`, matching `sdk/metric.WithProducer`, and by `ProfilerProvider` for single-reader setups or stateless snapshot producers.
    +
    +Do not share a stateful producer that tracks delta baselines or continuous capture windows across multiple independent readers. That includes `RuntimeProducer` with delta profiles or CPU profiling enabled. Each `Produce` call advances delta baselines and rotates the CPU buffer, so an on-demand `ManualReader` collection would consume data meant for the next `PeriodicReader` export. Attach a separate `RuntimeProducer` to each reader via reader-level `WithProducer` when readers need independent intervals. When multiple destinations need the same collected batch, including process-wide CPU profiling where Go permits only one active profiler, fan out at the `Exporter` layer instead.
    +
    +`RuntimeProducer` collects profiles from Go's `runtime/pprof` and decodes them with an internal zero-dependency pprof wire decoder (`sdk/profile/internal/pprof`):
    +
    +```go
    +type RuntimeProducer struct { /* ... */ }
    +
    +func NewRuntimeProducer(opts ...RuntimeProducerOption) *RuntimeProducer
    +func (*RuntimeProducer) Produce(ctx context.Context) ([]profiledata.ScopeProfiles, error)
    +func (*RuntimeProducer) Shutdown(ctx context.Context) error
    +
    +type RuntimeProducerOption interface { /* unexported */ }
    +func WithHeapProfile() RuntimeProducerOption
    +func WithoutHeapProfile() RuntimeProducerOption
    +func WithAllocsProfile() RuntimeProducerOption
    +func WithoutAllocsProfile() RuntimeProducerOption
    +func WithGoroutineProfile() RuntimeProducerOption
    +func WithoutGoroutineProfile() RuntimeProducerOption
    +func WithCPUProfile() RuntimeProducerOption
    +func WithoutDeltaProfiles() RuntimeProducerOption
    +```
    +
    +| Profile kind | Default | Mode | Scope suffix | Runtime side effects |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Live heap (`inuse_space`, `inuse_objects`) | Enabled | Instantaneous snapshot | `.../runtime/heap` | None |
    +| Allocations (`alloc_space`, `alloc_objects`) | Enabled | Interval delta (opt-out via `WithoutDeltaProfiles`) | `.../runtime/allocs` | None |
    +| Goroutines (`goroutine`) | Enabled | Instantaneous snapshot | `.../runtime/goroutine` | None |
    +| CPU (`cpu`, `samples`) | Opt-in (`WithCPUProfile`) | Double-buffered continuous window | `.../runtime/cpu` | Claims process-wide `pprof.StartCPUProfile`, stopped on `Shutdown` |
    +
    +Go's `mutex` and `block` profiles are deferred from the initial `v0.0.0` `RuntimeProducer`. Both emit identical `sample_type` pairs (`contentions`/`count` and `delay`/`nanoseconds`), so backends cannot distinguish them on the OTLP wire until the upstream spec defines a profile-identifying attribute (see [spec PR #5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409#discussion_r4534499496)). Deferring them also keeps global runtime rate mutation (`runtime.SetMutexProfileFraction`, `runtime.SetBlockProfileRate`) out of the initial release. When added in Phase 3, both will be opt-in with reference-counted rate restoration on `Shutdown`.
    +
    +Implementation invariants in `RuntimeProducer` and `sdk/profile/internal/pprof`:
    +
    +- `BuildIDCache` reads and caches `process.executable.build_id.htlhash`, Go build ID, and GNU ELF build ID per binary path per [Profiles Mappings Attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/mappings.md).
    +- Converted profiles emit `pprof.scope.default_sample_type`, `pprof.scope.sample_type_order`, `profile.frame.type = "go"`, and `pprof.mapping.*` attributes per [Pprof Compatibility](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/profiles/pprof.md).
    +- Samples carrying valid `otel.trace_id` and `otel.span_id` pprof labels convert to `profiledata.Link` and drop those raw labels from sample attributes.
    +
    +## Reader, ManualReader, and PeriodicReader
    +
    +`Reader` mirrors `sdk/metric.Reader` with an unexported `register` method plus `Collect`, `ForceFlush`, and `Shutdown`:
    +
    +```go
    +type Reader interface {
    +	register(sdkProducer)
    +	Collect(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +- `ManualReader` supports on-demand collection in tests and custom pull pipelines.
    +- `PeriodicReader` runs a single background goroutine ticking on `WithInterval` (default `60s`) with per-cycle `WithTimeout` (default `30s`). `ForceFlush` triggers an immediate collect-and-export cycle and resets the ticker. `Shutdown` stops the loop, runs one final collect-and-export cycle, shuts down reader-attached producers, and shuts down the `Exporter`.
    +
    +## Exporter and OTLP transport
    +
    +```go
    +type Exporter interface {
    +	Export(ctx context.Context, rp *profiledata.ResourceProfiles) error
    +	ForceFlush(ctx context.Context) error
    +	Shutdown(ctx context.Context) error
    +}
    +```
    +
    +Implementations must honor `ctx` cancellation and deadlines and must not retain `rp` after `Export` returns.
    +
    +Both `otlpprofilehttp` and `otlpprofilegrpc` generate their `internal/transform` package from a single shared `gotmpl` template (`internal/shared/otlp/otlpprofile/transform/profile.go.tmpl`), parameterized by `protoRoot` (`go.opentelemetry.io/proto/slim/otlp` for HTTP and `go.opentelemetry.io/proto/otlp` for gRPC):
    +
    +- Dictionary invariants: index 0 of all seven tables (`StringTable`, `MappingTable`, `LocationTable`, `FunctionTable`, `LinkTable`, `AttributeTable`, `StackTable`) holds the zero-value sentinel. Entries are deduplicated by canonical OTLP wire representation (including across Go slice `attribute.Type` variants) and kept orphan-free. String keys and values use dictionary references (`KeyStrindex`, `StringValueStrindex`).
    +- `otlpprofilehttp` posts to `/v1development/profiles` on `localhost:4318` by default, sets `Content-Type: application/x-protobuf` and `OTLP-Profiles-Development-Version: 1`, reads `OTEL_EXPORTER_OTLP_PROFILES_*` with fallback to `OTEL_EXPORTER_OTLP_*`, supports gzip, `Retry-After` retries (`429`, `502`, `503`, `504`), partial-success (`rejected_profiles`) reporting, 64 MiB default max request size (checked via `proto.Size` before marshaling), and 4 MiB max decompressed response size.
    +- `otlpprofilegrpc` shares the same environment variables, sends `otlp-profiles-development-version: 1` gRPC metadata, and supports TLS/mTLS, gzip, `RetryInfo` throttling, and partial-success reporting.
    +
    +## Trace context correlation
    +
    +`sdk/profile/internal/pprof.Convert` already parses `otel.trace_id` and `otel.span_id` pprof labels into `profiledata.Sample.Link`, while `RuntimeProducer` does not automatically write goroutine pprof labels when spans start.
    +
    +Two complementary mechanisms cover trace correlation in Go:
    +
    +1. In-process pprof labels (planned follow-up): an opt-in helper or `sdk/trace` integration that attaches `otel.trace_id` and `otel.span_id` via `runtime/pprof.Do` or `runtime/pprof.SetGoroutineLabels` on span start/end. Stdlib `runtime/pprof` currently attaches goroutine labels to CPU and goroutine profiles, not heap, allocs, mutex, or block profiles.
    +2. Out-of-process context sharing ([OTEP 4719](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4719-process-ctx.md) / [spec PR #5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370) and [OTEP 4947](https://github.com/open-telemetry/opentelemetry-specification/blob/main/oteps/profiles/4947-thread-ctx.md)): `ProcessContext` publishes process `Resource` for eBPF profilers, while `ThreadContext` uses ELF TLS, which does not directly map to Go's M:N goroutine scheduler without runtime hooks. Keeping `sdk/profile` decoupled lets both evolve independently.
    +
    +## Cross-language alignment and OTel specification
    +
    +[`opentelemetry-specification/specification/profiles/`](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/profiles) currently covers the wire data format, mapping attributes, pprof compatibility, and open PRs for well-known `sample_type`/`period_type` values ([#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409)) and Process Context Sharing ([#5370](https://github.com/open-telemetry/opentelemetry-specification/pull/5370)). There is no Profiles SDK specification yet.
    +
    +Comparing this design with [OTel .NET's `ContinuousProfiler`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation/ContinuousProfiler) and [`PluginApi/ContinuousProfiling`](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/tree/main/src/OpenTelemetry.AutoInstrumentation.PluginApi/ContinuousProfiling) highlights what belongs in an upstream OTel specification versus language SDKs:
    +
    +| Dimension | OTel Go `sdk/profile` | OTel .NET `ContinuousProfiler` | OTel eBPF Profiler | Upstream OTel Spec candidate |
    +| :--- | :--- | :--- | :--- | :--- |
    +| Pipeline lifecycle | `ProfilerProvider`, `Producer`, `Reader` (`PeriodicReader` / `ManualReader`), `Exporter` | `ContinuousProfilerManager`, `SampleExporter` loop, `BufferProcessor`, `IContinuousProfilerExporter` | eBPF ring buffer to collector pipeline | Yes: `ProfilerProvider`, `ProfileReader`, `ProfileProducer`, `ProfileExporter`, `ForceFlush`, `Shutdown` |
    +| Scheduling knobs | `interval` (`60s`), `timeout` (`30s`) | Per-sample-type `ExportInterval`, `ExportTimeout` | Collection interval | Yes: `OTEL_PROFILES_EXPORTER`, `OTEL_PROFILES_EXPORT_INTERVAL`, `OTEL_PROFILES_EXPORT_TIMEOUT` |
    +| Exporter input | Typed `profiledata.ResourceProfiles` | Raw native `byte[]` buffers | OTLP `Profiles` | Yes: OTLP-aligned typed profile data model |
    +| Runtime profile knobs | `heap`, `allocs`, `goroutine`, opt-in `cpu`, delta flag (deferred: `mutex`, `block`) | `ThreadSamplingInterval`, `MaxAllocationSamplesPerMinute`, `SelectedThreads` | Perf events | No: keep runtime-specific; standardize `(sample_type, unit)` names via spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409) |
    +| Trace correlation | `otel.trace_id` / `otel.span_id` pprof labels to `Sample.Link` | CLR thread-local active `Activity` + `SelectiveSampling` | `ProcessContext` + `ThreadContext` | Yes: contract to populate `Sample.Link`, leaving the hook mechanism per runtime |
    +| OTLP exporter config | `OTEL_EXPORTER_OTLP_PROFILES_*`, `/v1development/profiles`, `OTLP-Profiles-Development-Version: 1` | Plugin-provided exporter | OTLP/gRPC | Yes: formalize in `specification/protocol/exporter.md` |
    +
    +## Phased plan
    +
    +1. Design consensus (this PR): align on module naming (`sdk/profile`), pull-based `Reader`/`Producer` model, protobuf-free `profiledata`, and default-safe `RuntimeProducer` behavior.
    +2. Experimental SDK and OTLP exporters: land [#9545](https://github.com/open-telemetry/opentelemetry-go/pull/9545) (`sdk/profile` core and `profiledata`), [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558) (`sdk/profile/internal/pprof`), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559) (`RuntimeProducer`), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546) (`otlpprofilehttp`), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547) (`otlpprofilegrpc`) at `v0.0.0`.
    +3. Follow-up Go SDK PRs: opt-in `mutex` and `block` profiles (with reference-counted rate restoration) once the upstream spec settles distinguishing profiles with identical `sample_type` values, opt-in trace-context pprof label integration (with overhead benchmarks), `OTEL_PROFILES_*` environment configuration, `stdoutprofile` exporter, `exporters/README.md` update, and alignment with finalized `sample_type`/`period_type` values from spec PR [#5409](https://github.com/open-telemetry/opentelemetry-specification/pull/5409).
    +4. Upstream OpenTelemetry specification: propose `OTEL_EXPORTER_OTLP_PROFILES_*` and `/v1development/profiles` in `specification/protocol/exporter.md`, then bring this Go design and the .NET comparison to the Profiling SIG as an OTEP for `specification/profiles/sdk.md`.
    +
    +## Benchmarking
    +
    +Benchmarks cover pprof decoding/conversion (`BenchmarkParseAndConvertHeap`, `BenchmarkRuntimeProducerProduce`) and OTLP dictionary construction (`BenchmarkExportRequest`) without network I/O. Baseline `benchstat` results are tracked in [#9558](https://github.com/open-telemetry/opentelemetry-go/pull/9558), [#9559](https://github.com/open-telemetry/opentelemetry-go/pull/9559), [#9546](https://github.com/open-telemetry/opentelemetry-go/pull/9546), and [#9547](https://github.com/open-telemetry/opentelemetry-go/pull/9547).
    +
    +## Open questions
    +
    +- Should `PeriodicReader` read `OTEL_PROFILES_EXPORT_INTERVAL` and `OTEL_PROFILES_EXPORT_TIMEOUT` now, or wait until environment variable names are formalized upstream in `opentelemetry-specification`?
    +- Should in-process trace-context correlation live as a `sdk/trace.SpanProcessor` / wrapper in `sdk/profile` (adding a dependency from `sdk/profile` on `sdk/trace`) or in a separate bridge package?

    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.

    bwplotka bwplotka commented on Nov 26, 2026 07:51 UTC
    Author

    Thanks for the detailed review, what could be the next steps?

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 07:51 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Clarify that block profiling rates cannot be restored · New

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document the same-goroutine requirement for restoring pprof labels · New

  • </details>

    <details>
    <summary><strong>1 resolved since last review</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Clarify SDK dependencies are inherited, not absent

  • </details>

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 07:56 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document the same-goroutine requirement for restoring pprof labels

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Clarify that block profiling rates cannot be restored

  • </details>

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 08:00 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document the same-goroutine requirement for restoring pprof labels

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Clarify that block profiling rates cannot be restored

  • </details>

    <sub>Review effort: Balanced</sub>

    pellared pellared commented on Nov 26, 2026 15:07 UTC
    Reviewer

    Thanks for this PR!

    pellared pellared commented on Nov 26, 2026 15:36 UTC
    Reviewer

    Follow-up review of the Profiles SDK design.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 16:33 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document that direct Collect consumes intervals without exporting · New

  • </details>

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 26, 2026 16:41 UTC
    Reviewer

    <!-- 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>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/low-v2-light.png" alt="Low severity" width="62" height="18" align="texttop"></picture> Document that direct Collect consumes intervals without exporting

  • </details>

    <sub>Review effort: Balanced</sub>

    bwplotka bwplotka commented on Nov 26, 2026 16:42 UTC
    Author

    I think we can close this and move the discussion upstream: https://github.com/open-telemetry/opentelemetry-specification/pull/5476

    pellared pellared commented on Nov 26, 2026 16:53 UTC
    Contributor

    @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

    pellared pellared commented on Nov 26, 2026 17:39 UTC
    Contributor

    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.

    bwplotka bwplotka commented on Dec 03, 2026 07:49 UTC
    Author

    @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.

    dashpole dashpole commented on Dec 03, 2026 15:55 UTC
    Contributor

    LGTM, but let's land the OTEP first.

    opentelemetry-pr-dashboard[bot] opentelemetry-pr-dashboard[bot] commented on Dec 03, 2026 18:23 UTC
    Bot

    <!-- 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.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard rechecks who needs to act once nothing on the list is waiting on you.

  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.
  • Reviewers
    Assignees
    bwplotka bwplotka
    Labels
    risk: low confidence: 83.8% 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: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    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: 83.8% · Lower = rushed or shallow review
    83.8%
    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: 8.1% · Safe to merge
    8.1%