Skip to content

Commit

Permalink
fix(inputs.kafka_consumer): use mutex for parser
Browse files Browse the repository at this point in the history
Using parsers like json_v2 will result in undesired parser results. This
adds a mutex to calls to the parser to prevent side effects from calling
the parser in parallel.
  • Loading branch information
toanju committed Sep 7, 2023
1 parent 7dcdc89 commit f88cffa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/inputs/kafka_consumer/kafka_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ func (h *ConsumerGroupHandler) Handle(session sarama.ConsumerGroupSession, msg *
len(msg.Value), h.MaxMessageLen)
}

h.mu.Lock()
metrics, err := h.parser.Parse(msg.Value)
h.mu.Unlock()
if err != nil {
h.release()
return err
Expand Down

0 comments on commit f88cffa

Please sign in to comment.