Skip to content

Commit 29c1038

Browse files
authored
Fix auto-decoder with json (#815)
1 parent d17a58c commit 29c1038

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

pipeline/pipeline.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,22 @@ func (p *Pipeline) In(sourceID SourceID, sourceName string, offsets Offsets, byt
428428
)
429429
if p.decoderType == decoder.AUTO {
430430
dec = p.suggestedDecoderType
431+
if dec == decoder.NO {
432+
dec = decoder.JSON
433+
}
434+
435+
// When config decoder is set to "auto", then we didn't create a decoder during pipeline initialization.
436+
// It's necessary to initialize the decoder once.
437+
if dec == decoder.JSON {
438+
p.initDecoderOnce.Do(func() {
439+
p.decoder, _ = decoder.NewJsonDecoder(p.settings.DecoderParams)
440+
})
441+
}
431442
} else {
432443
dec = p.decoderType
433444
}
434-
if dec == decoder.NO {
435-
dec = decoder.JSON
436-
// When config decoder is set to "auto", then we didn't create a decoder during pipeline initialization.
437-
// It's necessary to initialize the decoder once.
438-
p.initDecoderOnce.Do(func() {
439-
p.decoder, _ = decoder.NewJsonDecoder(nil)
440-
})
441-
} else if dec == decoder.CRI {
445+
446+
if dec == decoder.CRI {
442447
row, err = decoder.DecodeCRI(bytes)
443448
if err != nil {
444449
p.wrongEventCRIFormatMetric.Inc()

0 commit comments

Comments
 (0)