Fix data race with default tags (#4395)
This commit is contained in:
@@ -388,21 +388,11 @@ func (a *Agent) Run(shutdown chan struct{}) error {
|
|||||||
}(aggregator)
|
}(aggregator)
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(len(a.Config.Inputs))
|
// Service inputs may immediately add metrics, if metrics are added before
|
||||||
for _, input := range a.Config.Inputs {
|
// the aggregator starts they will be dropped. Generally this occurs
|
||||||
interval := a.Config.Agent.Interval.Duration
|
// only during testing but it is an outstanding issue.
|
||||||
// overwrite global interval if this plugin has it's own.
|
//
|
||||||
if input.Config.Interval != 0 {
|
// https://github.com/influxdata/telegraf/issues/4394
|
||||||
interval = input.Config.Interval
|
|
||||||
}
|
|
||||||
go func(in *models.RunningInput, interv time.Duration) {
|
|
||||||
defer wg.Done()
|
|
||||||
a.gatherer(shutdown, in, interv, metricC)
|
|
||||||
}(input, interval)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start all ServicePlugins inputs after all other
|
|
||||||
// plugins are loaded so that no metrics get dropped
|
|
||||||
for _, input := range a.Config.Inputs {
|
for _, input := range a.Config.Inputs {
|
||||||
input.SetDefaultTags(a.Config.Tags)
|
input.SetDefaultTags(a.Config.Tags)
|
||||||
switch p := input.Input.(type) {
|
switch p := input.Input.(type) {
|
||||||
@@ -420,6 +410,19 @@ func (a *Agent) Run(shutdown chan struct{}) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Add(len(a.Config.Inputs))
|
||||||
|
for _, input := range a.Config.Inputs {
|
||||||
|
interval := a.Config.Agent.Interval.Duration
|
||||||
|
// overwrite global interval if this plugin has it's own.
|
||||||
|
if input.Config.Interval != 0 {
|
||||||
|
interval = input.Config.Interval
|
||||||
|
}
|
||||||
|
go func(in *models.RunningInput, interv time.Duration) {
|
||||||
|
defer wg.Done()
|
||||||
|
a.gatherer(shutdown, in, interv, metricC)
|
||||||
|
}(input, interval)
|
||||||
|
}
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
a.Close()
|
a.Close()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user