diff --git a/plugins/inputs/nsq/nsq.go b/plugins/inputs/nsq/nsq.go index 11399ffaa221c..e53c0ca04d078 100644 --- a/plugins/inputs/nsq/nsq.go +++ b/plugins/inputs/nsq/nsq.go @@ -68,13 +68,17 @@ const ( func init() { inputs.Add("nsq", func() telegraf.Input { - return &NSQ{ - httpClientOnce: &sync.Once{}, - tlsConfigOnce: &sync.Once{}, - } + return New() }) } +func New() *NSQ { + return &NSQ{ + httpClientOnce: &sync.Once{}, + tlsConfigOnce: &sync.Once{}, + } +} + func (n *NSQ) SampleConfig() string { return sampleConfig } diff --git a/plugins/inputs/nsq/nsq_test.go b/plugins/inputs/nsq/nsq_test.go index f3e9ce8689a64..1d3b541e5f1ce 100644 --- a/plugins/inputs/nsq/nsq_test.go +++ b/plugins/inputs/nsq/nsq_test.go @@ -19,9 +19,8 @@ func TestNSQStatsV1(t *testing.T) { })) defer ts.Close() - n := &NSQ{ - Endpoints: []string{ts.URL}, - } + n := New() + n.Endpoints = []string{ts.URL} var acc testutil.Accumulator err := acc.GatherError(n.Gather) @@ -276,9 +275,8 @@ func TestNSQStatsPreV1(t *testing.T) { })) defer ts.Close() - n := &NSQ{ - Endpoints: []string{ts.URL}, - } + n := New() + n.Endpoints = []string{ts.URL} var acc testutil.Accumulator err := acc.GatherError(n.Gather)