Fix tags applied to wrong metric on parse error (#5650)
This commit is contained in:
		
							parent
							
								
									0d00f0af3c
								
							
						
					
					
						commit
						c283e5992a
					
				|  | @ -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() | ||||
| } | ||||
|  |  | |||
|  | @ -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 | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue