Skip to content

oss_11_m1_metric_cardinality_limit#17

Open
ocelotl wants to merge 2 commits into
mainfrom
oss_11_m1_metric_cardinality_limit
Open

oss_11_m1_metric_cardinality_limit#17
ocelotl wants to merge 2 commits into
mainfrom
oss_11_m1_metric_cardinality_limit

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Closes #16

Implements M1 (base layer) of metric cardinality limits (Linear OSS-11, findings M1–M3): _ViewInstrumentMatch now 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

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.
@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🔒 Internal (dash0) — not for upstream.

@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

📣 Public-facing draft — to be opened upstream in open-telemetry/opentelemetry-python. No internal references; copy verbatim.

Title: Enforce a default metric aggregation cardinality limit with an overflow series

What

_ViewInstrumentMatch now enforces a default aggregation cardinality limit of 2000. Once the number of tracked attribute sets would exceed the limit, previously-unseen attribute sets are aggregated into a single overflow series identified by {"otel.metric.overflow": true} (one slot is reserved so the total number of points never exceeds the limit). A warning is logged once, the first time overflow occurs.

Why

The 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.

Scope

This is the base default limit only. Follow-ups will add a per-MetricReader default and a per-View override.

Testing

New integration test for the cardinality limit + overflow behavior; full metrics suite passes (306).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oss_11_m1_metric_cardinality_limit

1 participant