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.

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