Skip to content

Conversation

@xuan-cao-swi
Copy link
Contributor

Description

This PR introduces cardinality limits for metric attributes, as defined in the metrics SDK specification.

Users can configure the cardinality limit in two ways:

  1. Through a view:
OpenTelemetry.meter_provider.add_view(
  'test_histogram',
  aggregation: OpenTelemetry::SDK::Metrics::Aggregation::ExplicitBucketHistogram.new,
  aggregation_cardinality_limit: 1
)
  1. Through an exporter:
exporter_with_limit = ConsoleMetricPullExporter.new(aggregation_cardinality_limit: 100)

If no limit is provided, the default value of 2000 is used (also negative value will turn to 0 for the limit).

The cardinality limit is enforced during the aggregation update process. When the number of unique attribute combinations exceeds the limit, the extra data points are grouped into a separate data point with the attribute:

{ 'otel.metric.overflow' => true }

This overflow data point is treated like any other data point.

Future work: There is currently duplicated logic across different aggregation implementations. A shared base aggregation class should be introduced to reduce repetition.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale label Dec 4, 2025
@github-actions github-actions bot removed the stale label Dec 6, 2025
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.

1 participant