Add mutex to influx parser

This commit is contained in:
Daniel Nelson 2018-04-02 12:52:23 -07:00
parent 7e3ec16e15
commit 64b239663c
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package influx
import (
"errors"
"fmt"
"sync"
"github.com/influxdata/telegraf"
)
@ -32,6 +33,7 @@ func (e *ParseError) Error() string {
type Parser struct {
DefaultTags map[string]string
sync.Mutex
*machine
handler *MetricHandler
}
@ -44,6 +46,8 @@ func NewParser(handler *MetricHandler) *Parser {
}
func (p *Parser) Parse(input []byte) ([]telegraf.Metric, error) {
p.Lock()
defer p.Unlock()
metrics := make([]telegraf.Metric, 0)
p.machine.SetData(input)