decoder

package
v0.0.0-...-eb3d71d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

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 AutoMultilineHandler

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

AutoMultilineHandler aggreagates multiline logs.

func NewAutoMultilineHandler

func NewAutoMultilineHandler(outputFn func(m *message.Message), maxContentSize int, flushTimeout time.Duration, tailerInfo *status.InfoRegistry) *AutoMultilineHandler

NewAutoMultilineHandler creates a new auto multiline handler.

type Decoder

type Decoder struct {
	InputChan  chan *message.Message
	OutputChan chan *message.Message
	// contains filtered or unexported fields
}

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 (*Decoder) GetDetectedPattern

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

GetDetectedPattern returns a detected pattern (if any)

func (*Decoder) GetLineCount

func (d *Decoder) GetLineCount() int64

GetLineCount returns the number of decoded lines

func (*Decoder) Start

func (d *Decoder) Start()

Start starts the Decoder

func (*Decoder) Stop

func (d *Decoder) Stop()

Stop stops the Decoder

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 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.

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 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 automultilinedetection contains auto multiline detection and aggregation logic.
Package automultilinedetection contains auto multiline detection and aggregation logic.
tokens
Package tokens contains the token definitions for the tokenizer.
Package tokens contains the token definitions for the tokenizer.

Jump to

Keyboard shortcuts

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