Merge pull request #453 from prometheus/mr/guard-logger-fsm

mapper: Make sure we have a logger before backtracking check
This commit is contained in:
Matthias Rampke 2022-07-29 15:06:37 +00:00 committed by GitHub
commit af84364004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,6 +233,10 @@ func (m *MetricMapper) InitFromYAMLString(fileContents string) error {
m.mutex.Lock()
defer m.mutex.Unlock()
if m.Logger == nil {
m.Logger = log.NewNopLogger()
}
m.Defaults = n.Defaults
m.Mappings = n.Mappings
@ -259,10 +263,6 @@ func (m *MetricMapper) InitFromYAMLString(fileContents string) error {
m.MappingsCount.Set(float64(len(n.Mappings)))
}
if m.Logger == nil {
m.Logger = log.NewNopLogger()
}
return nil
}