Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogsUnmarshalerDecoderFactory ¶ added in v0.148.0
func NewLogsUnmarshalerDecoderFactory(unmarshaler plog.Unmarshaler) encoding.LogsDecoderFactory
NewLogsUnmarshalerDecoderFactory returns an encoding.LogsDecoderFactory that reads the full stream into memory and delegates to the provided plog.Unmarshaler.
func NewMetricsUnmarshalerDecoderFactory ¶ added in v0.148.0
func NewMetricsUnmarshalerDecoderFactory(unmarshaler pmetric.Unmarshaler) encoding.MetricsDecoderFactory
NewMetricsUnmarshalerDecoderFactory returns an encoding.MetricsDecoderFactory that reads the full stream into memory and delegates to the provided pmetric.Unmarshaler.
Types ¶
type BatchHelper ¶
type BatchHelper struct {
// contains filtered or unexported fields
}
BatchHelper is a helper to determine when to flush based on configured options. It tracks the current byte and item counts and compares them against configured thresholds. Not safe for concurrent use.
func NewBatchHelper ¶
func NewBatchHelper(opts ...encoding.DecoderOption) *BatchHelper
NewBatchHelper creates a new BatchHelper with the provided options.
func (*BatchHelper) IncrementBytes ¶
func (sh *BatchHelper) IncrementBytes(n int64)
IncrementBytes adds n to the current byte count.
func (*BatchHelper) IncrementItems ¶
func (sh *BatchHelper) IncrementItems(n int64)
IncrementItems adds n to the current item count.
func (*BatchHelper) Options ¶
func (sh *BatchHelper) Options() encoding.DecoderOptions
Options returns the DecoderOptions used by the BatchHelper.
func (*BatchHelper) Reset ¶
func (sh *BatchHelper) Reset()
Reset resets the current byte and item counts to zero. Should be called after flushing a batch to start tracking the next batch.
func (*BatchHelper) ShouldFlush ¶
func (sh *BatchHelper) ShouldFlush() bool
ShouldFlush returns true if the current counts exceed configured thresholds. Make sure to call Reset after flushing to start tracking the next batch.
type LogsDecoderAdapter ¶
type LogsDecoderAdapter struct {
// contains filtered or unexported fields
}
LogsDecoderAdapter adapts decode and offset functions to implement encoding.LogsDecoder.
func NewLogsDecoderAdapter ¶
func NewLogsDecoderAdapter(decode func() (plog.Logs, error), offset func() int64) LogsDecoderAdapter
NewLogsDecoderAdapter creates a new LogsDecoderAdapter with the provided decode and offset functions.
func (LogsDecoderAdapter) DecodeLogs ¶
func (a LogsDecoderAdapter) DecodeLogs() (plog.Logs, error)
func (LogsDecoderAdapter) Offset ¶
func (a LogsDecoderAdapter) Offset() int64
type MetricsDecoderAdapter ¶
type MetricsDecoderAdapter struct {
// contains filtered or unexported fields
}
MetricsDecoderAdapter adapts decode and offset functions to implement encoding.MetricsDecoder.
func NewMetricsDecoderAdapter ¶
func NewMetricsDecoderAdapter(decode func() (pmetric.Metrics, error), offset func() int64) MetricsDecoderAdapter
NewMetricsDecoderAdapter creates a new MetricsDecoderAdapter with the provided decode and offset functions.
func (MetricsDecoderAdapter) DecodeMetrics ¶
func (a MetricsDecoderAdapter) DecodeMetrics() (pmetric.Metrics, error)
func (MetricsDecoderAdapter) Offset ¶
func (a MetricsDecoderAdapter) Offset() int64
type ScannerHelper ¶
type ScannerHelper struct {
// contains filtered or unexported fields
}
ScannerHelper is a helper to scan new line delimited records from io.Reader and determine when to flush. It uses new line delimiters and bytes for batching. Not safe for concurrent use.
func NewScannerHelper ¶
func NewScannerHelper(reader io.Reader, opts ...encoding.DecoderOption) (*ScannerHelper, error)
NewScannerHelper creates a new ScannerHelper that reads from the provided io.Reader. It accepts optional encoding.DecoderOption to configure batch flushing behavior. If a bufio.Reader is provided, it will be used as-is. Otherwise, one will be derived with default buffer size.
func (*ScannerHelper) Offset ¶
func (h *ScannerHelper) Offset() int64
Offset returns the current byte offset read from the stream.
func (*ScannerHelper) Options ¶
func (h *ScannerHelper) Options() encoding.DecoderOptions
Options returns the DecoderOptions used by the ScannerHelper's BatchHelper.
func (*ScannerHelper) ScanBytes ¶
func (h *ScannerHelper) ScanBytes() (bytes []byte, flush bool, err error)
ScanBytes scans the next line from the stream and returns it as a byte slice. This excludes new line delimiter. flush indicates whether the batch should be flushed after processing these bytes. err is non-nil if an error occurred during scanning. If the end of the stream is reached, err will be io.EOF.
func (*ScannerHelper) ScanString ¶
func (h *ScannerHelper) ScanString() (line string, flush bool, err error)
ScanString scans the next line from the stream and returns it as a string. This excludes new line delimiter. flush indicates whether the batch should be flushed after processing this string. err is non-nil if an error occurred during scanning. If the end of the stream is reached, err will be io.EOF.