open-telemetry / open-telemetry/opentelemetry-cpp

[METRICS SDK] Synchronous instruments with drop aggregation must behave as no-op

Open
#4,514 0 comments 1 reaction 1 assignee View on GitHub

@dbarker is already working on this.

Since Sep 1, 2026.

bug triage/accepted
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)

  1. Update the SDK meter to not create storage for a view with Drop aggregation
  2. 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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.