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)
- 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:
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)).
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. Add a boolean flag (and public const accessor) toSyncWritableMetricStoragethat is set to true if drop aggregation is configured.2. For each Record method ofSyncMetricStorageandSyncMultiMetricStoragereturn 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