Check parser initialization earlier

This commit is contained in:
Daniel Nelson 2018-02-15 18:24:49 -08:00
parent 0851de714d
commit 0d683f65a3
1 changed files with 4 additions and 4 deletions

View File

@ -88,6 +88,10 @@ func (*HTTP) Description() string {
// Gather takes in an accumulator and adds the metrics that the Input // Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval" // gathers. This is called every "interval"
func (h *HTTP) Gather(acc telegraf.Accumulator) error { func (h *HTTP) Gather(acc telegraf.Accumulator) error {
if h.parser == nil {
return errors.New("Parser is not set")
}
if h.client == nil { if h.client == nil {
tlsCfg, err := internal.GetTLSConfig( tlsCfg, err := internal.GetTLSConfig(
h.SSLCert, h.SSLKey, h.SSLCA, h.InsecureSkipVerify) h.SSLCert, h.SSLKey, h.SSLCA, h.InsecureSkipVerify)
@ -170,10 +174,6 @@ func (h *HTTP) gatherURL(
return err return err
} }
if h.parser == nil {
return errors.New("Parser is not set")
}
metrics, err := h.parser.Parse(b) metrics, err := h.parser.Parse(b)
if err != nil { if err != nil {
return err return err