open-telemetry / open-telemetry/opentelemetry-cpp
[METRICS SDK] Synchronous instruments with drop aggregation must behave as no-op
@dbarker is already working on this.
Since Sep 1, 2026.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
Background:
The sync instrument benchmarks measure recording latency when instruments are disabled (created from a disabled meter) and when drop aggregation is configured through a view. The results show instruments with drop aggregation produce significantly higher latency than a disabled instrument (See https://github.com/open-telemetry/opentelemetry-cpp/pull/4470#discussion_r3836923932).
| Instrument | Disabled | Drop Aggregation | Overhead vs. Disabled |
|---|---|---|---|
| Counter (threads:1) | 0.223 ns | 181 ns | 812x |
| Counter (threads:2) | 0.334 ns | 336 ns | 1006x |
| Counter (threads:4) | 0.335 ns | 548 ns | 1636x |
| Histogram Explicit (threads:1) | 0.215 ns | 180 ns | 837x |
| Histogram Explicit (threads:2) | 0.215 ns | 198 ns | 921x |
| Histogram Explicit (threads:4) | 0.227 ns | 556 ns | 2450x |
The drop aggregation path can be optimized to behave like a no-op instrument and avoid the costly attribute hashing and thread synchronization.
Scope:
(edit)
- Update the SDK meter to not create storage for a view with Drop aggregation
- Update tests to cover configuring drop aggregation with a single instrument view and catch-all views
1. Add a boolean flag (and public const accessor) to SyncWritableMetricStorage that is set to true if drop aggregation is configured.
2. For each Record method of SyncMetricStorage and SyncMultiMetricStorage return early (before taking any locks) if drop aggregation is configured.
Related spec requirements:
An instrument should behave as a no-op if the meter is disabled or if all views of the instrument resolve to drop aggregation.
https://opentelemetry.io/docs/specs/otel/metrics/sdk/#instrument-enabled
https://opentelemetry.io/docs/specs/otel/metrics/sdk/#drop-aggregation
If a Meter is disabled, it MUST behave equivalently to No-op Meter.
The value of enabled MUST be used to resolve whether an instrument is Enabled. See Instrument Enabled for details.
The synchronous instrument Enabled MUST return false when either:
- Status: Development - The MeterConfig of the Meter used to create the instrument has parameter enabled=false.
- All resolved views for the instrument are configured with the Drop Aggregation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.