OTLP: Upgrade prometheus/otlptranslator

The upgrade to prometheus/otlptranslator@7f02967de0 fixes two label
name translation bugs, when in legacy name translation mode:
* 'key' is no longer prefixed when label names start with an underscore
* Multiple consecutive underscores are combined into one

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen 2025-09-09 08:48:50 +02:00
parent 09814effe6
commit 7cf4b5da55
2 changed files with 11 additions and 1 deletions

View file

@ -88,7 +88,11 @@ func (c *PrometheusConverter) createAttributes(resource pcommon.Resource, attrib
c.scratchBuilder.Sort()
sortedLabels := c.scratchBuilder.Labels()
labelNamer := otlptranslator.LabelNamer{UTF8Allowed: settings.AllowUTF8}
labelNamer := otlptranslator.LabelNamer{
UTF8Allowed: settings.AllowUTF8,
UnderscoreLabelSanitization: settings.LabelNameUnderscoreLabelSanitization,
PreserveMultipleUnderscores: settings.LabelNamePreserveMultipleUnderscores,
}
if settings.AllowUTF8 {
// UTF8 is allowed, so conflicts aren't possible.

View file

@ -54,6 +54,12 @@ type Settings struct {
// PromoteScopeMetadata controls whether to promote OTel scope metadata to metric labels.
PromoteScopeMetadata bool
EnableTypeAndUnitLabels bool
// LabelNameUnderscoreLabelSanitization controls whether to enable prepending of 'key' to labels
// starting with '_'. Reserved labels starting with `__` are not modified.
LabelNameUnderscoreLabelSanitization bool
// LabelNamePreserveMultipleUnderscores enables preserving of multiple
// consecutive underscores in label names when AllowUTF8 is false.
LabelNamePreserveMultipleUnderscores bool
}
// PrometheusConverter converts from OTel write format to Prometheus remote write format.