8000 Default for OTLPConfig not computed when ``otlp`` unset · Issue #16688 · prometheus/prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Default for OTLPConfig not computed when otlp unset #16688
Closed
@celian-garcia

Description

@celian-garcia

What did you do?

I'm enabling otlp receiver with following argument

- '--web.enable-otlp-receiver'

and on purpose unset the otlp config field (to leverage default)

# otlp: 
#   translation_strategy: UnderscoreEscapingWithSuffixes

What did you expect to see?

I still expect the otlp metrics to be translated with underscore as UnderscoreEscapingWithSuffixes should be the default.

What did you see instead? Under which circumstances?

Instead, the default config is not computed, and the strategy is to not translate. Metrics are not translated with underscores.

I think this is due to the fact that the UnmarshalYAML is not called if the field is unset

prometheus/config/config.go

Lines 1530 to 1562 in d9c0ad1

type OTLPConfig struct {
PromoteResourceAttributes []string `yaml:"promote_resource_attributes,omitempty"`
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
KeepIdentifyingResourceAttributes bool `yaml:"keep_identifying_resource_attributes,omitempty"`
ConvertHistogramsToNHCB bool `yaml:"convert_histograms_to_nhcb,omitempty"`
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (c *OTLPConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultOTLPConfig
type plain OTLPConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
}
seen := map[string]struct{}{}
var err error
for i, attr := range c.PromoteResourceAttributes {
attr = strings.TrimSpace(attr)
if attr == "" {
err = errors.Join(err, errors.New("empty promoted OTel resource attribute"))
continue
}
if _, exists := seen[attr]; exists {
err = errors.Join(err, fmt.Errorf("duplicated promoted OTel resource attribute %q", attr))
continue
}
seen[attr] = struct{}{}
c.PromoteResourceAttributes[i] = attr
}
return err
}

I see that some defaults are computed on parent structure, and this is what should be done for OTLP config here since the enablement of it is not done inside the structure but via an argument

prometheus/config/config.go

Lines 379 to 381 in d9c0ad1

if c.GlobalConfig.isZero() {
c.GlobalConfig = DefaultGlobalConfig
}

System information

No response

Prometheus version

3.4.1

Prometheus configuration file

Alertmanager version


Alertmanager configuration file

Logs


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0