sdk/metric: Support specifying cardinality limits per instrument kinds#7855
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7855 +/- ##
=====================================
Coverage 81.7% 81.7%
=====================================
Files 308 308
Lines 23632 23655 +23
=====================================
+ Hits 19320 19343 +23
- Misses 3928 3929 +1
+ Partials 384 383 -1
🚀 New features to boost your workflow:
|
fd48f36 to
56c399f
Compare
dashpole
left a comment
There was a problem hiding this comment.
This does not follow what is in the specification.
If there is no matching view, but the
MetricReaderdefines a default
cardinality limit value based on the instrument an aggregation is created
for, that value SHOULD be used.
This does not suggest that the metric reader needs configuration allowing the cardinality limit to be changed per-instrument-kind. It only suggests that the default value chosen by the SDK can be based on the instrument.
The correct specification for this configuration is here
aggregation_cardinality_limit: A positive integer value defining the
maximum number of data points allowed to be emitted in a collection cycle by
a single instrument. See cardinality limits, below.
Users can provide an
aggregation_cardinality_limit, but it is up to their
discretion. Therefore, the stream configuration parameter needs to be
structured to accept anaggregation_cardinality_limit, but MUST NOT
obligate a user to provide one. If the user does not provide an
aggregation_cardinality_limitvalue, theMeterProviderMUST apply the
default aggregation cardinality limit theMetricReaderis
configured with.
|
I've opened open-telemetry/opentelemetry-configuration#524 to fix this in the configuration. |
|
Got it, thanks. I largely just blindly followed the issue, but I definitely also felt it was strange based on the spec. Left a comment on the issue you created, we'll see where it goes, considering other sdks have implemented it. |
|
Ok, so this needs to be configuration on the metric reader, not the MeterProvider.
So this should be a function that takes an instrument kind, and returns a cardinality limit. |
|
gentle bump @dashpole. Could you review again? |
…m falling back to global value
Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: David Ashpole <dashpole@google.com>
8338181 to
c5471d9
Compare
|
Three approvals already. Are we waiting on anything else before merging? |
Release issue: #8127 ## Added - Add `IsRandom` and `WithRandom` on `TraceFlags`, and `IsRandom` on `SpanContext` in `go.opentelemetry.io/otel/trace` for [W3C Trace Context Level 2 Random Trace ID Flag](https://www.w3.org/TR/trace-context-2/#random-trace-id-flag) support. (#8012) - Add service detection with `WithService` in `go.opentelemetry.io/otel/sdk/resource`. (#7642) - Add `DefaultWithContext` and `EnvironmentWithContext` in `go.opentelemetry.io/otel/sdk/resource` to support plumbing `context.Context` through default and environment detectors. (#8051) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8038) - Support attributes with empty value (`attribute.EMPTY`) in `go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#8038) - Add support for per-series start time tracking for cumulative metrics in `go.opentelemetry.io/otel/sdk/metric`. Set `OTEL_GO_X_PER_SERIES_START_TIMESTAMPS=true` to enable. (#8060) - Add `WithCardinalityLimitSelector` for metric reader for configuring cardinality limits specific to the instrument kind. (#7855) ## Changed - Introduce the `EMPTY` Type in `go.opentelemetry.io/otel/attribute` to reflect that an empty value is now a valid value, with `INVALID` remaining as a deprecated alias of `EMPTY`. (#8038) - Refactor slice handling in `go.opentelemetry.io/otel/attribute` to optimize short slice values with fixed-size fast paths. (#8039) - Improve performance of span metric recording in `go.opentelemetry.io/otel/sdk/trace` by returning early if self-observability is not enabled. (#8067) - Improve formatting of metric data diffs in `go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#8073) ## Deprecated - Deprecate `INVALID` in `go.opentelemetry.io/otel/attribute`. Use `EMPTY` instead. (#8038) ## Fixed - Return spec-compliant `TraceIdRatioBased` description. This is a breaking behavioral change, but it is necessary to make the implementation [spec-compliant](https://opentelemetry.io/docs/specs/otel/trace/sdk/#traceidratiobased). (#8027) - Fix a race condition in `go.opentelemetry.io/otel/sdk/metric` where the lastvalue aggregation could collect the value 0 even when no zero-value measurements were recorded. (#8056) - Limit HTTP response body to 4 MiB in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` to mitigate excessive memory usage caused by a misconfigured or malicious server. Responses exceeding the limit are treated as non-retryable errors. (#8108) - Limit HTTP response body to 4 MiB in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` to mitigate excessive memory usage caused by a misconfigured or malicious server. Responses exceeding the limit are treated as non-retryable errors. (#8108) - Limit HTTP response body to 4 MiB in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` to mitigate excessive memory usage caused by a misconfigured or malicious server. Responses exceeding the limit are treated as non-retryable errors. (#8108) - `WithHostID` detector in `go.opentelemetry.io/otel/sdk/resource` to use full path for `kenv` command on BSD. (#8113) - Fix missing `request.GetBody` in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` to correctly handle HTTP2 GOAWAY frame. (#8096) --------- Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Previously, we only had
WithCardinalityLimit(), which adds a global cardinality limit.This PR adds a new API on the reader
WithCardinalityLimitSelectorthat can be used to specify limits per instrument kinds.spec
schema
closes #7786