oss_11_m1_metric_cardinality_limit#17
Conversation
Add a base aggregation cardinality limit (default 2000) in _ViewInstrumentMatch.consume_measurement. Once the number of tracked attribute sets reaches the limit, previously unseen attribute sets are aggregated into a single overflow series identified by the attribute otel.metric.overflow=true, instead of allocating a new series per attribute set. This bounds metrics SDK memory under attribute explosion. One slot is reserved for the overflow series so the total number of metric points never exceeds the limit, matching the Go and Java implementations.
|
🔒 Internal (dash0) — not for upstream.
|
|
📣 Public-facing draft — to be opened upstream in Title: Enforce a default metric aggregation cardinality limit with an overflow series What
WhyThe metrics SDK previously tracked every distinct attribute set without bound and emitted no overflow series, so an attribute-value explosion grew memory without limit. This implements the base ("M1") layer of the spec's cardinality-limit requirement, matching the Go and Java reference implementations. ScopeThis is the base default limit only. Follow-ups will add a per- TestingNew integration test for the cardinality limit + overflow behavior; full metrics suite passes (306). |
Closes #16
Implements M1 (base layer) of metric cardinality limits (Linear OSS-11, findings M1–M3):
_ViewInstrumentMatchnow enforces a default aggregation cardinality limit (2000). Once the number of tracked attribute sets would exceed the limit, previously-unseen attribute sets are aggregated into a single overflow series{'otel.metric.overflow': True}(one slot reserved so total points never exceed the limit), matching the Go/Java reference implementations. A warning is logged once when overflow first occurs.M2 (per-MetricReader default) and M3 (per-View override) remain and will be tracked as their own stacked PRs.
Validation: contained to the metrics SDK + tests + changelog; new cardinality test (3 passed) and full metrics suite (306 passed).
Linear issue: https://linear.app/dash0/issue/OSS-11/m1-m3-metric-cardinality-limits-base-per-reader-per-view