From 0d683f65a3a6f3363ee654936d6848b11fd0236f Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Thu, 15 Feb 2018 18:24:49 -0800 Subject: [PATCH] Check parser initialization earlier --- plugins/inputs/http/http.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/http/http.go b/plugins/inputs/http/http.go index 00a13e3f3..5bf895ca5 100644 --- a/plugins/inputs/http/http.go +++ b/plugins/inputs/http/http.go @@ -88,6 +88,10 @@ func (*HTTP) Description() string { // Gather takes in an accumulator and adds the metrics that the Input // gathers. This is called every "interval" func (h *HTTP) Gather(acc telegraf.Accumulator) error { + if h.parser == nil { + return errors.New("Parser is not set") + } + if h.client == nil { tlsCfg, err := internal.GetTLSConfig( h.SSLCert, h.SSLKey, h.SSLCA, h.InsecureSkipVerify) @@ -170,10 +174,6 @@ func (h *HTTP) gatherURL( return err } - if h.parser == nil { - return errors.New("Parser is not set") - } - metrics, err := h.parser.Parse(b) if err != nil { return err