mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
Remove configuration parameters
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
3de3a296dd
commit
f5804e7cf2
7 changed files with 6 additions and 75 deletions
|
|
@ -258,9 +258,7 @@ var (
|
|||
|
||||
// DefaultOTLPConfig is the default OTLP configuration.
|
||||
DefaultOTLPConfig = OTLPConfig{
|
||||
TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes,
|
||||
LabelNameUnderscoreSanitization: true,
|
||||
LabelNamePreserveMultipleUnderscores: true,
|
||||
TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -1611,14 +1609,6 @@ type OTLPConfig struct {
|
|||
// PromoteScopeMetadata controls whether to promote OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
|
||||
// As per OTel spec, the aforementioned scope metadata should be identifying, i.e. made into metric labels.
|
||||
PromoteScopeMetadata bool `yaml:"promote_scope_metadata,omitempty"`
|
||||
// LabelNameUnderscoreSanitization controls whether to enable prepending of 'key_' to labels
|
||||
// starting with '_'. Reserved labels starting with `__` are not modified.
|
||||
// This is only relevant when AllowUTF8 is false (i.e., when using underscore escaping).
|
||||
LabelNameUnderscoreSanitization bool `yaml:"label_name_underscore_sanitization,omitempty"`
|
||||
// LabelNamePreserveMultipleUnderscores enables preserving of multiple consecutive underscores
|
||||
// in label names when AllowUTF8 is false. When false, multiple consecutive underscores are
|
||||
// collapsed to a single underscore during label name sanitization.
|
||||
LabelNamePreserveMultipleUnderscores bool `yaml:"label_name_preserve_multiple_underscores,omitempty"`
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
|
|
|
|||
|
|
@ -175,9 +175,7 @@ var expectedConf = &Config{
|
|||
PromoteResourceAttributes: []string{
|
||||
"k8s.cluster.name", "k8s.job.name", "k8s.namespace.name",
|
||||
},
|
||||
TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes,
|
||||
LabelNameUnderscoreSanitization: true,
|
||||
LabelNamePreserveMultipleUnderscores: true,
|
||||
TranslationStrategy: otlptranslator.UnderscoreEscapingWithSuffixes,
|
||||
},
|
||||
|
||||
RemoteReadConfigs: []*RemoteReadConfig{
|
||||
|
|
@ -1844,48 +1842,6 @@ func TestOTLPPromoteScopeMetadata(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestOTLPLabelUnderscoreSanitization(t *testing.T) {
|
||||
t.Run("defaults to true", func(t *testing.T) {
|
||||
conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_defaults.good.yml"), false, promslog.NewNopLogger())
|
||||
require.NoError(t, err)
|
||||
|
||||
// Test that default values are true
|
||||
require.True(t, conf.OTLPConfig.LabelNameUnderscoreSanitization)
|
||||
require.True(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores)
|
||||
})
|
||||
|
||||
t.Run("explicit enabled", func(t *testing.T) {
|
||||
conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_enabled.good.yml"), false, promslog.NewNopLogger())
|
||||
require.NoError(t, err)
|
||||
|
||||
out, err := yaml.Marshal(conf)
|
||||
require.NoError(t, err)
|
||||
var got Config
|
||||
require.NoError(t, yaml.UnmarshalStrict(out, &got))
|
||||
|
||||
require.True(t, got.OTLPConfig.LabelNameUnderscoreSanitization)
|
||||
require.True(t, got.OTLPConfig.LabelNamePreserveMultipleUnderscores)
|
||||
})
|
||||
|
||||
t.Run("explicit disabled", func(t *testing.T) {
|
||||
conf, err := LoadFile(filepath.Join("testdata", "otlp_label_underscore_sanitization_disabled.good.yml"), false, promslog.NewNopLogger())
|
||||
require.NoError(t, err)
|
||||
|
||||
// When explicitly set to false, they should be false
|
||||
require.False(t, conf.OTLPConfig.LabelNameUnderscoreSanitization)
|
||||
require.False(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores)
|
||||
})
|
||||
|
||||
t.Run("empty config uses defaults", func(t *testing.T) {
|
||||
conf, err := LoadFile(filepath.Join("testdata", "otlp_empty.yml"), false, promslog.NewNopLogger())
|
||||
require.NoError(t, err)
|
||||
|
||||
// Empty config should use default values (true)
|
||||
require.True(t, conf.OTLPConfig.LabelNameUnderscoreSanitization)
|
||||
require.True(t, conf.OTLPConfig.LabelNamePreserveMultipleUnderscores)
|
||||
})
|
||||
}
|
||||
|
||||
func TestOTLPAllowUTF8(t *testing.T) {
|
||||
t.Run("good config - NoUTF8EscapingWithSuffixes", func(t *testing.T) {
|
||||
fpath := filepath.Join("testdata", "otlp_allow_utf8.good.yml")
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
otlp:
|
||||
promote_resource_attributes: ["service.name"]
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
otlp:
|
||||
label_name_underscore_sanitization: false
|
||||
label_name_preserve_multiple_underscores: false
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
otlp:
|
||||
label_name_underscore_sanitization: true
|
||||
label_name_preserve_multiple_underscores: true
|
||||
|
|
@ -222,15 +222,6 @@ otlp:
|
|||
# Enables promotion of OTel scope metadata (i.e. name, version, schema URL, and attributes) to metric labels.
|
||||
# This is disabled by default for backwards compatibility, but according to OTel spec, scope metadata _should_ be identifying, i.e. translated to metric labels.
|
||||
[ promote_scope_metadata: <boolean> | default = false ]
|
||||
# Controls whether to enable prepending of 'key_' to labels starting with '_'.
|
||||
# Reserved labels starting with '__' are not modified.
|
||||
# This is only relevant when translation_strategy uses underscore escaping
|
||||
# (e.g., "UnderscoreEscapingWithSuffixes" or "UnderscoreEscapingWithoutSuffixes").
|
||||
[ label_name_underscore_sanitization: <boolean> | default = true ]
|
||||
# Enables preserving of multiple consecutive underscores in label names when
|
||||
# translation_strategy uses underscore escaping. When true (default), multiple
|
||||
# consecutive underscores are preserved during label name sanitization.
|
||||
[ label_name_preserve_multiple_underscores: <boolean> | default = true ]
|
||||
|
||||
# Settings related to the remote read feature.
|
||||
remote_read:
|
||||
|
|
|
|||
|
|
@ -658,8 +658,10 @@ func (rw *rwExporter) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) er
|
|||
AllowDeltaTemporality: rw.allowDeltaTemporality,
|
||||
LookbackDelta: rw.lookbackDelta,
|
||||
EnableTypeAndUnitLabels: rw.enableTypeAndUnitLabels,
|
||||
LabelNameUnderscoreSanitization: otlpCfg.LabelNameUnderscoreSanitization,
|
||||
LabelNamePreserveMultipleUnderscores: otlpCfg.LabelNamePreserveMultipleUnderscores,
|
||||
// For backwards compatibility.
|
||||
LabelNameUnderscoreSanitization: true,
|
||||
// For backwards compatibility.
|
||||
LabelNamePreserveMultipleUnderscores: true,
|
||||
})
|
||||
|
||||
defer func() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue