decoder

package
v0.0.0-...-bae2e76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package decoder provides log line decoding and parsing functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInput

func NewInput(content []byte) *message.Message

NewInput returns a new decoder input. A decoder input is an unstructured message of raw bytes as the content. Some of the tailers using this are the file tailers and socket tailers as these logs don't have any structure, they're just raw bytes log. See message.Message / message.MessageContent comment for more information.

Types

type Decoder

type Decoder interface {
	Start()
	Stop()
	GetLineCount() int64
	GetDetectedPattern() *regexp.Regexp
	InputChan() chan *message.Message
	OutputChan() chan *message.Message
}

Decoder translates a sequence of byte buffers (such as from a file or a network socket) into log messages.

Decoder is structured as an actor receiving messages on `InputChan` and writing its output in `OutputChan`

The Decoder's run() takes data from InputChan, uses a Framer to break it into frames. The Framer passes that data to a LineParser, which uses a Parser to parse it and to pass it to the LineHander.

The LineHandler processes the messages it as necessary (as single lines, multiple lines, or auto-detecting the two), and sends the result to the Decoder's output channel.

func InitializeDecoder

func InitializeDecoder(source *sources.ReplaceableSource, parser parsers.Parser, tailerInfo *status.InfoRegistry) Decoder

InitializeDecoder returns a properly initialized Decoder

func New

func New(InputChan chan *message.Message, OutputChan chan *message.Message, framer *framer.Framer, lineParser LineParser, lineHandler LineHandler, detectedPattern *DetectedPattern) Decoder

New returns an initialized Decoder

func NewDecoderFromSource

func NewDecoderFromSource(source *sources.ReplaceableSource, tailerInfo *status.InfoRegistry) Decoder

NewDecoderFromSource creates a new decoder from a log source

func NewDecoderFromSourceWithPattern

func NewDecoderFromSourceWithPattern(source *sources.ReplaceableSource, multiLinePattern *regexp.Regexp, tailerInfo *status.InfoRegistry) Decoder

NewDecoderFromSourceWithPattern creates a new decoder from a log source with a multiline pattern

func NewDecoderWithFraming

func NewDecoderWithFraming(source *sources.ReplaceableSource, parser parsers.Parser, framing framer.Framing, multiLinePattern *regexp.Regexp, tailerInfo *status.InfoRegistry) Decoder

NewDecoderWithFraming initialize a decoder with given endline strategy.

func NewNoopDecoder

func NewNoopDecoder() Decoder

NewNoopDecoder initializes a decoder with all dependent components in passthrough mode.

type DetectedPattern

type DetectedPattern struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DetectedPattern is a container to safely access a detected multiline pattern

func (*DetectedPattern) Get

func (d *DetectedPattern) Get() *regexp.Regexp

Get gets the pattern

func (*DetectedPattern) Set

func (d *DetectedPattern) Set(pattern *regexp.Regexp)

Set sets the pattern

type LegacyAutoMultilineHandler

type LegacyAutoMultilineHandler struct {
	// contains filtered or unexported fields
}

LegacyAutoMultilineHandler can attempts to detect a known/commob pattern (a timestamp) in the logs and will switch to a MultiLine handler if one is detected and the thresholds are met.

func NewLegacyAutoMultilineHandler

func NewLegacyAutoMultilineHandler(
	outputFn func(*message.Message),
	lineLimit, linesToAssess int,
	matchThreshold float64,
	matchTimeout time.Duration,
	flushTimeout time.Duration,
	source *sources.ReplaceableSource,
	additionalPatterns []*regexp.Regexp,
	detectedPattern *DetectedPattern,
	tailerInfo *status.InfoRegistry,
) *LegacyAutoMultilineHandler

NewLegacyAutoMultilineHandler returns a new LegacyAutoMultilineHandler.

type LineHandler

type LineHandler interface {
	// contains filtered or unexported methods
}

LineHandler handles raw lines to form structured lines.

type LineParser

type LineParser interface {
	// contains filtered or unexported methods
}

LineParser handles decoded lines, parsing them into decoder.Message's using an embedded parsers.Parser.

type MockDecoder

type MockDecoder struct {
	// contains filtered or unexported fields
}

MockDecoder is a mock decoder that can be used to test the decoder

func NewMockDecoder

func NewMockDecoder() *MockDecoder

NewMockDecoder creates a new mock decoder

func NewMockDecoderWithOptions

func NewMockDecoderWithOptions(options *MockDecoderOptions) *MockDecoder

NewMockDecoderWithOptions creates a new mock decoder with the given options

func (*MockDecoder) GetDetectedPattern

func (d *MockDecoder) GetDetectedPattern() *regexp.Regexp

GetDetectedPattern returns the detected pattern (if any)

func (*MockDecoder) GetLineCount

func (d *MockDecoder) GetLineCount() int64

GetLineCount returns the number of decoded lines

func (*MockDecoder) InputChan

func (d *MockDecoder) InputChan() chan *message.Message

InputChan returns the input channel

func (*MockDecoder) OutputChan

func (d *MockDecoder) OutputChan() chan *message.Message

OutputChan returns the output channel

func (*MockDecoder) Start

func (d *MockDecoder) Start()

Start starts the mock decoder

func (*MockDecoder) Stop

func (d *MockDecoder) Stop()

Stop stops the mock decoder

type MockDecoderOptions

type MockDecoderOptions struct {
	InputChanSize  int
	OutputChanSize int
}

MockDecoderOptions are the options for creating a mock decoder

type MultiLineHandler

type MultiLineHandler struct {
	// contains filtered or unexported fields
}

MultiLineHandler makes sure that multiple lines from a same content are properly put together.

func NewMultiLineHandler

func NewMultiLineHandler(outputFn func(*message.Message), newContentRe *regexp.Regexp, flushTimeout time.Duration, lineLimit int, telemetryEnabled bool, tailerInfo *status.InfoRegistry, multiLineTagValue string) *MultiLineHandler

NewMultiLineHandler returns a new MultiLineHandler.

func (*MultiLineHandler) CountInfo

func (h *MultiLineHandler) CountInfo() *status.CountInfo

Satisfy the multiLineCountable interface to use syncSourceInfo function

func (*MultiLineHandler) LinesCombinedInfo

func (h *MultiLineHandler) LinesCombinedInfo() *status.CountInfo

func (*MultiLineHandler) SetCountInfo

func (h *MultiLineHandler) SetCountInfo(info *status.CountInfo)

func (*MultiLineHandler) SetLinesCombinedInfo

func (h *MultiLineHandler) SetLinesCombinedInfo(info *status.CountInfo)

type MultiLineParser

type MultiLineParser struct {
	// contains filtered or unexported fields
}

MultiLineParser makes sure that chunked lines are properly put together.

func NewMultiLineParser

func NewMultiLineParser(
	lineHandler LineHandler,
	flushTimeout time.Duration,
	parser parsers.Parser,
	lineLimit int,
) *MultiLineParser

NewMultiLineParser returns a new MultiLineParser.

type NoopLineHandler

type NoopLineHandler struct {
	// contains filtered or unexported fields
}

NoopLineHandler provides a passthrough functionality for flows that don't need a functional line handler

func NewNoopLineHandler

func NewNoopLineHandler(outputChan chan *message.Message) *NoopLineHandler

NewNoopLineHandler returns a new NoopLineHandler

type SingleLineHandler

type SingleLineHandler struct {
	// contains filtered or unexported fields
}

SingleLineHandler takes care of tracking the line length and truncating them when they are too long.

func NewSingleLineHandler

func NewSingleLineHandler(outputFn func(*message.Message), lineLimit int) *SingleLineHandler

NewSingleLineHandler returns a new SingleLineHandler.

type SingleLineParser

type SingleLineParser struct {
	// contains filtered or unexported fields
}

SingleLineParser makes sure that multiple lines from a same content are properly put together.

func NewSingleLineParser

func NewSingleLineParser(
	lineHandler LineHandler,
	parser parsers.Parser) *SingleLineParser

NewSingleLineParser returns a new SingleLineParser.

Directories

Path Synopsis
Package preprocessor contains auto multiline detection and aggregation logic.
Package preprocessor contains auto multiline detection and aggregation logic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL