After upgrading from go.opentelemetry.io/otel/exporters/prometheus v0.50.0 to go.opentelemetry.io/otel/exporters/prometheus v0.53.0 I see the following error exemplar label name \"wg.operation.hash\" is invalid.
We use a custom view to filter metric attributes with high cardinality. While the metric is definitely dropped in the view it seems the data is still exported on the prometheus exporter.
var opts []sdkmetric.Option
// Exclude attributes from metrics
attributeFilter := func(value attribute.KeyValue) bool {
if isKeyInSlice(value.Key, defaultExcludedOtelKeys) {
return false
}
name := sanitizeName(string(value.Key))
for _, re := range c.Prometheus.ExcludeMetricLabels {
if re.MatchString(name) {
return false
}
}
return true
}
msBucketHistogram := sdkmetric.AggregationExplicitBucketHistogram{
Boundaries: msBucketsBounds,
}
bytesBucketHistogram := sdkmetric.AggregationExplicitBucketHistogram{
Boundaries: bytesBucketBounds,
}
var view sdkmetric.View = func(i sdkmetric.Instrument) (sdkmetric.Stream, bool) {
// In a custom View function, we need to explicitly copy the name, description, and unit.
s := sdkmetric.Stream{Name: i.Name, Description: i.Description, Unit: i.Unit}
// Use different histogram buckets for PrometheusConfig
if i.Unit == unitBytes && i.Kind == sdkmetric.InstrumentKindHistogram {
s.Aggregation = bytesBucketHistogram
} else if i.Unit == unitMilliseconds && i.Kind == sdkmetric.InstrumentKindHistogram {
s.Aggregation = msBucketHistogram
}
// Filter out metrics that match the excludeMetrics regexes
for _, re := range c.Prometheus.ExcludeMetrics {
promName := sanitizeName(i.Name)
if re.MatchString(promName) {
// Drop the metric
s.Aggregation = sdkmetric.AggregationDrop{}
return s, true
}
}
// Filter out attributes that match the excludeMetricAttributes regexes
s.AttributeFilter = attributeFilter
return s, true
}
opts = append(opts, sdkmetric.WithView(view))
Description
After upgrading from
go.opentelemetry.io/otel/exporters/prometheus v0.50.0
togo.opentelemetry.io/otel/exporters/prometheus v0.53.0
I see the following errorexemplar label name \"wg.operation.hash\" is invalid
.We use a custom view to filter metric attributes with high cardinality. While the metric is definitely dropped in the view it seems the data is still exported on the prometheus exporter.
It is necessary to checkout https://github.com/open-telemetry/opentelemetry-go/commit/664a075380b9eb155512adb1213ca688bd1ed611 to not run into a different exemplar prometheus issue.
Stacktrace of the OTEL error
Environment
Expected behavior
It should be possible to filter attributes like before including prometheus exporter support