Fix tags applied to wrong metric on parse error (#5650)

This commit is contained in:
Daniel Nelson 2019-04-02 11:14:56 -07:00
parent 0d00f0af3c
commit c283e5992a
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
2 changed files with 6 additions and 0 deletions

View File

@ -118,3 +118,7 @@ func (h *MetricHandler) SetTimestamp(tm []byte) error {
h.builder.SetTime(time.Unix(0, ns))
return nil
}
func (h *MetricHandler) Reset() {
h.builder.Reset()
}

View File

@ -75,6 +75,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
}
if err != nil {
p.handler.Reset()
return nil, &ParseError{
Offset: p.machine.Position(),
LineOffset: p.machine.LineOffset(),
@ -87,6 +88,7 @@ func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
metric, err := p.handler.Metric()
if err != nil {
p.handler.Reset()
return nil, err
}