mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Sanitize configured OTel resource attributes
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
a25b626792
commit
ae82a0a941
|
@ -19,6 +19,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1318,5 +1319,22 @@ type OTLPConfig struct {
|
||||||
func (c *OTLPConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *OTLPConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
*c = DefaultOTLPConfig
|
*c = DefaultOTLPConfig
|
||||||
type plain OTLPConfig
|
type plain OTLPConfig
|
||||||
return unmarshal((*plain)(c))
|
if err := unmarshal((*plain)(c)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
seen := map[string]struct{}{}
|
||||||
|
i := 0
|
||||||
|
for i < len(c.PromoteResourceAttributes) {
|
||||||
|
s := strings.TrimSpace(c.PromoteResourceAttributes[i])
|
||||||
|
if _, exists := seen[s]; exists {
|
||||||
|
c.PromoteResourceAttributes = slices.Delete(c.PromoteResourceAttributes, i, i+1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
seen[s] = struct{}{}
|
||||||
|
c.PromoteResourceAttributes[i] = s
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue