Repository navigation
Conversation
Pull request dashboard statusClosed · refreshed 2026-11-04 15:22 UTC Status above doesn't look right?
|
aa1fa4f to
61cb319
Compare
Update prometheus receiver to dynamically exclude any internal label starting with `__` from being added as OTLP datapoint attributes, rather than relying on a hardcoded list of internal labels.
61cb319 to
f96a9f6
Compare
Restore __name__, __scheme__, and __metrics_path__ to notUsefulLabelsOther and add isExtraInternalLabel so standard scraped series avoid allocating per-series exclusion slices, add unit and allocation regression tests, and trim changelog subtext.
krajorama
left a comment
There was a problem hiding this comment.
I'm not sure about this at all, see comment.
| @@ -491,6 +491,10 @@ func getScopeID(ls labels.Labels) (scopeID, pcommon.Map, bool) { | |||
| var attrs pcommon.Map | |||
| var hasAttrs, hasScopeLabels bool | |||
| ls.Range(func(lbl labels.Label) { | |||
| if isExtraInternalLabel(lbl.Name) { | |||
| hasScopeLabels = true | |||
There was a problem hiding this comment.
nit the hasScopeLabels variable name is now misleading everywhere, I'm not sure what I'd name this
| @@ -491,6 +491,10 @@ func getScopeID(ls labels.Labels) (scopeID, pcommon.Map, bool) { | |||
| var attrs pcommon.Map | |||
| var hasAttrs, hasScopeLabels bool | |||
| ls.Range(func(lbl labels.Label) { | |||
| if isExtraInternalLabel(lbl.Name) { | |||
| hasScopeLabels = true | |||
| return | |||
There was a problem hiding this comment.
Does this mean that if two series only differed in a reserved (__.*) label , they would now make those series conflict? That could lead to some unexpected results - and it's breaking change.
I think we should just log a warning if we see such label, but not enforce Prometheus rules that Prometheus itself doesn't enforce. AFAIK Prometheus will happily scrape or add during metric relabelling reserved names, so making this change would not let the collector be a drop in replacement for Prometheus.
There was a problem hiding this comment.
You're right — Prometheus strips __* labels from target labels in Target.LabelsRange, but preserves any __* labels exposed by the target or added via metric_relabel_configs. Closing this in favor of #52736.
Description:
Update the prometheus receiver to dynamically exclude any internal label starting with
__from being added as OTLP datapoint attributes, rather than relying on a hardcoded list of internal labels (such asmodel.SchemeLabel,model.MetricsPathLabel, etc.).This allows the receiver to properly exclude all standard internal prometheus labels that may be present during translation, as opposed to only a limited subset.
Testing:
Added unit and benchmark allocation regression tests in
metricfamily_test.goandtransaction_test.goverifying internal__label exclusion and zero-allocation series ref hashing.