sdk/metric: Add WithCardinalityLimit option#6996
sdk/metric: Add WithCardinalityLimit option#6996pellared merged 30 commits intoopen-telemetry:mainfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6996 +/- ##
=====================================
Coverage 82.7% 82.8%
=====================================
Files 261 261
Lines 24341 24361 +20
=====================================
+ Hits 20154 20175 +21
+ Misses 3812 3811 -1
Partials 375 375
🚀 New features to boost your workflow:
|
…s://github.com/ysolomchenko/opentelemetry-go into define-cardinality-limit-configuration-options
Co-authored-by: Robert Pająk <pellared@hotmail.com>
pellared
left a comment
There was a problem hiding this comment.
Overall LGTM. Just a few nit comments that I would like to get addressed.
Probably we can consider improving the WithCardinalityLimit Go Doc, but it is not a blocker to me and the refinements could be scoped to a separate PR.
|
My suggestion is to keep it no limit for now, mention that no limit will be deprecated, and in next releases change it to 2000. |
In theory, this seems reasonable as it gives users time to configure the value higher than 2000 if needed. However, I’m not sure people would actually know they’re about to hit the 2000 cardinality limit. Because of that, I suspect it wouldn’t really help and might just add unnecessary complexity on us. Personally, I’d try following the specification’s recommendation and set the default cardinality limit to 2000 right away. We should also include a prominent warning in the One thing I haven’t checked yet: does setting a cardinality limit impact performance? If so, that could be a valid argument against making 2000 the default. Given all this, I’d suggest creating a separate issue to discuss changing the default cardinality limit, so we can gather input and proceed carefully, while allowing other work to continue in parallel. |
|
Here is benchstat no limit vs 2000 limit |
|
updated Changelog entry for highlighting cardinality limit as a breaking change. |
|
Given the performance overhead and the worry of breaking users I think it is reasonable to keep the "no limit" as default. If there is still a will to change the default value, we can create a separate issue for tracking as proposed here. |
Out of curiosity, what is the reason why enforcing cardinality limit causes a metric update to take additional 10ns? (Based on my experience implementing this in .NET, Rust there was no measurable overhead/no overhead at all. When a new attribute combination is seen, a check must be done to ensure if adding this would cross the limit. But for updating existing attributes, there is no change (i.e not even a single extra instruction)...) |
Co-authored-by: Damien Mathieu <42@dmathieu.com>
I created #7035 for tracking as nobody responded so far. |
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
|
We are going to track the discussion about the default in a follow-up issue. Going to merge this to progress the work on adding this feature. |
This release is the last to support [Go 1.23]. The next release will require at least [Go 1.24]. ### Added - Add native histogram exemplar support in `go.opentelemetry.io/otel/exporters/prometheus`. (#6772) - Add template attribute functions to the `go.opentelmetry.io/otel/semconv/v1.34.0` package. (#6939) - `ContainerLabel` - `DBOperationParameter` - `DBSystemParameter` - `HTTPRequestHeader` - `HTTPResponseHeader` - `K8SCronJobAnnotation` - `K8SCronJobLabel` - `K8SDaemonSetAnnotation` - `K8SDaemonSetLabel` - `K8SDeploymentAnnotation` - `K8SDeploymentLabel` - `K8SJobAnnotation` - `K8SJobLabel` - `K8SNamespaceAnnotation` - `K8SNamespaceLabel` - `K8SNodeAnnotation` - `K8SNodeLabel` - `K8SPodAnnotation` - `K8SPodLabel` - `K8SReplicaSetAnnotation` - `K8SReplicaSetLabel` - `K8SStatefulSetAnnotation` - `K8SStatefulSetLabel` - `ProcessEnvironmentVariable` - `RPCConnectRPCRequestMetadata` - `RPCConnectRPCResponseMetadata` - `RPCGRPCRequestMetadata` - `RPCGRPCResponseMetadata` - Add `ErrorType` attribute helper function to the `go.opentelmetry.io/otel/semconv/v1.34.0` package. (#6962) - Add `WithAllowKeyDuplication` in `go.opentelemetry.io/otel/sdk/log` which can be used to disable deduplication for log records. (#6968) - Add `WithCardinalityLimit` option to configure the cardinality limit in `go.opentelemetry.io/otel/sdk/metric`. (#6996, #7065, #7081, #7164, #7165, #7179) - Add `Clone` method to `Record` in `go.opentelemetry.io/otel/log` that returns a copy of the record with no shared state. (#7001) - Add experimental self-observability span and batch span processor metrics in `go.opentelemetry.io/otel/sdk/trace`. Check the `go.opentelemetry.io/otel/sdk/trace/internal/x` package documentation for more information. (#7027, #6393, #7209) - The `go.opentelemetry.io/otel/semconv/v1.36.0` package. The package contains semantic conventions from the `v1.36.0` version of the OpenTelemetry Semantic Conventions. See the [migration documentation](./semconv/v1.36.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.34.0.`(#7032, #7041) - Add support for configuring Prometheus name translation using `WithTranslationStrategy` option in `go.opentelemetry.io/otel/exporters/prometheus`. The current default translation strategy when UTF-8 mode is enabled is `NoUTF8EscapingWithSuffixes`, but a future release will change the default strategy to `UnderscoreEscapingWithSuffixes` for compliance with the specification. (#7111) - Add experimental self-observability log metrics in `go.opentelemetry.io/otel/sdk/log`. Check the `go.opentelemetry.io/otel/sdk/log/internal/x` package documentation for more information. (#7121) - Add experimental self-observability trace exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`. Check the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace/internal/x` package documentation for more information. (#7133) - Support testing of [Go 1.25]. (#7187) - The `go.opentelemetry.io/otel/semconv/v1.37.0` package. The package contains semantic conventions from the `v1.37.0` version of the OpenTelemetry Semantic Conventions. See the [migration documentation](./semconv/v1.37.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.36.0.`(#7254) ### Changed - Optimize `TraceIDFromHex` and `SpanIDFromHex` in `go.opentelemetry.io/otel/sdk/trace`. (#6791) - Change `AssertEqual` in `go.opentelemetry.io/otel/log/logtest` to accept `TestingT` in order to support benchmarks and fuzz tests. (#6908) - Change `DefaultExemplarReservoirProviderSelector` in `go.opentelemetry.io/otel/sdk/metric` to use `runtime.GOMAXPROCS(0)` instead of `runtime.NumCPU()` for the `FixedSizeReservoirProvider` default size. (#7094) ### Fixed - `SetBody` method of `Record` in `go.opentelemetry.io/otel/sdk/log` now deduplicates key-value collections (`log.Value` of `log.KindMap` from `go.opentelemetry.io/otel/log`). (#7002) - Fix `go.opentelemetry.io/otel/exporters/prometheus` to not append a suffix if it's already present in metric name. (#7088) - Fix the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` self-observability component type and name. (#7195) - Fix partial export count metric in `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`. (#7199) ### Deprecated - Deprecate `WithoutUnits` and `WithoutCounterSuffixes` options, preferring `WithTranslationStrategy` instead. (#7111) - Deprecate support for `OTEL_GO_X_CARDINALITY_LIMIT` environment variable in `go.opentelemetry.io/otel/sdk/metric`. Use `WithCardinalityLimit` option instead. (#7166)
Fixes #6976
Towards #6887
What
Additional