Hello there!
I'm creating some new modules and metricsets and saw something odd, maybe a bug, or at least a possibility of an improvement
The possible problem: When we use the config "reload.enabled: false" (on the "metricbeat.config.modules" section, the default) all the metricset's New Methods are called two times.
What causes that, I think: "metricbeat/beater/metricbeat.go", in the Run method:
if bt.config.ConfigModules.Enabled() {
moduleReloader := cfgfile.NewReloader(b.Publisher, bt.config.ConfigModules)
if err := moduleReloader.Check(factory); err != nil { //me: this line ends up calling initMetricSets, that calls the New method
return err
}
go moduleReloader.Run(factory) //also me: this, too, ends up calling initMetricSets
wg.Add(1)
go func() {
defer wg.Done()
<-bt.done
moduleReloader.Stop()
}()
}
Sorry if I'm missing something, but is there a reason for the moduleReloader.Check realy create the metricset all the way through (metricbeat/mb/module/wrapper.go's NewWrapper calling mb.NewModule)? If we are just trying to anticipate a config error, wouldn't the reloader just do the same?
Best Regards