Skip to content

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

Description

@dbarker

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 #4470 (comment)).

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:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions