Add call to optional Init function for all plugins (#5899)

This commit is contained in:
Daniel Nelson
2019-06-14 15:12:27 -07:00
committed by GitHub
parent b35beb2fba
commit 0ff9c8ef88
12 changed files with 131 additions and 39 deletions

View File

@@ -52,6 +52,10 @@ var sampleConfig = `
drop_original = false
`
func (m *Min) Init() error {
return nil
}
func (m *Min) SampleConfig() string {
return sampleConfig
}

View File

@@ -52,6 +52,10 @@ func (s *Simple) SampleConfig() string {
`
}
func (s *Simple) Init() error {
return nil
}
func (s *Simple) Gather(acc telegraf.Accumulator) error {
if s.Ok {
acc.AddFields("state", map[string]interface{}{"value": "pretty good"}, nil)

View File

@@ -43,6 +43,10 @@ func (s *Simple) SampleConfig() string {
`
}
func (s *Simple) Init() error {
return nil
}
func (s *Simple) Connect() error {
// Make a connection to the URL here
return nil

View File

@@ -46,6 +46,10 @@ func (p *Printer) Description() string {
return "Print all metrics that pass through this filter."
}
func (p *Printer) Init() error {
return nil
}
func (p *Printer) Apply(in ...telegraf.Metric) []telegraf.Metric {
for _, metric := range in {
fmt.Println(metric.String())