forked from mirrors/statsd_exporter
mapper: Make sure we have a logger before backtracking check
The FSM backtracking detection issues a log line. Make sure there is a non-nil logger before doing that. Avoids the crash in prometheus/graphite_exporter#197. Signed-off-by: Matthias Rampke <matthias@prometheus.io>
This commit is contained in:
parent
c2505cf91e
commit
bc43c5606d
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue