Skip to content

sdk/metric: apply default cardinality limit of 2000#8247

Open
pellared wants to merge 5 commits intoopen-telemetry:mainfrom
pellared:card-limit-default
Open

sdk/metric: apply default cardinality limit of 2000#8247
pellared wants to merge 5 commits intoopen-telemetry:mainfrom
pellared:card-limit-default

Conversation

@pellared
Copy link
Copy Markdown
Member

@pellared pellared commented Apr 21, 2026

Per https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#cardinality-limits:

If none of the previous values are defined, the default value of 2000 SHOULD be used.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.6%. Comparing base (63ee0c5) to head (b7d787b).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8247   +/-   ##
=====================================
  Coverage   82.6%   82.6%           
=====================================
  Files        309     309           
  Lines      24621   24621           
=====================================
  Hits       20356   20356           
- Misses      3888    3889    +1     
+ Partials     377     376    -1     
Files with missing lines Coverage Δ
sdk/metric/config.go 95.2% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Applies the Metrics SDK specification-recommended default cardinality limit (2000) in go.opentelemetry.io/otel/sdk/metric, updating tests, docs, and changelog to reflect the new default and overflow behavior.

Changes:

  • Set the SDK default cardinality limit to 2000 (previously unlimited by default).
  • Update cardinality-limit tests to validate overflow aggregation behavior.
  • Refresh package docs, examples, and changelog to reflect the new default and migration guidance.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/metric/config.go Changes the default cardinality limit constant to 2000 and updates option docs.
sdk/metric/provider_test.go Adjusts cardinality limit tests for the new default and checks overflow datapoints.
sdk/metric/config_test.go Extends env-var parsing tests (including 0 to disable the limit).
sdk/metric/doc.go Updates package documentation to state the new default and describe overflow behavior.
sdk/metric/example_test.go Removes redundant explicit WithCardinalityLimit(2000) since it’s now default.
CHANGELOG.md Documents the default change and how to preserve unlimited cardinality.

Comment thread sdk/metric/provider_test.go
Comment thread sdk/metric/config.go
@pellared pellared marked this pull request as ready for review April 21, 2026 08:26
@pellared pellared requested a review from flc1125 as a code owner April 21, 2026 08:26
@dmathieu
Copy link
Copy Markdown
Member

I remember us making an explicit decision not to change that, as it was a breaking change.
I don't mind revisiting that decision, just pointing that out.

Copy link
Copy Markdown
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was initially opposed to doing this, but its becoming more of a wart with all of the CVE reports and with users expecting consistency with declarative config. I think as long as we keep the env var around for a while this is the best path forward.

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.

4 participants