logs

package
v3.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package logs defines types used for the data object logs section. The logs section holds a list of log records across multiple streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Iter

Iter iterates over records in the provided decoder. All logs sections are iterated over in order.

Types

type Logs

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

Logs accumulate a set of [Record]s within a data object.

func New

func New(metrics *Metrics, opts Options) *Logs

Nwe creates a new Logs section. The pageSize argument specifies how large pages should be.

func (*Logs) Append

func (l *Logs) Append(entry Record)

Append adds a new entry to the set of Logs.

func (*Logs) EncodeTo

func (l *Logs) EncodeTo(enc *encoding.Encoder) error

EncodeTo encodes the set of logs to the provided encoder. Before encoding, log records are sorted by StreamID and Timestamp.

EncodeTo may generate multiple sections if the list of log records is too big to fit into a single section.

Logs.Reset is invoked after encoding, even if encoding fails.

func (*Logs) EstimatedSize

func (l *Logs) EstimatedSize() int

EstimatedSize returns the estimated size of the Logs section in bytes.

func (*Logs) Reset

func (l *Logs) Reset()

Reset resets all state, allowing Logs to be reused.

type Metrics

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

Metrics instruments the logs section.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates a new set of metrics for the logs section.

func (*Metrics) Register

func (m *Metrics) Register(reg prometheus.Registerer) error

Register registers metrics to report to reg.

func (*Metrics) Unregister

func (m *Metrics) Unregister(reg prometheus.Registerer)

Unregister unregisters metrics from the provided Registerer.

type Options

type Options struct {
	// PageSizeHint is the size of pages to use when encoding the logs section.
	PageSizeHint int

	// BufferSize is the size of the buffer to use when accumulating log records.
	BufferSize int

	// SectionSizeHint is the size of the section to use when encoding the logs
	// section. If the section size is exceeded, multiple sections will be
	// created.
	SectionSize int
}

Options configures the behavior of the logs section.

type Record

type Record struct {
	StreamID  int64
	Timestamp time.Time
	Metadata  push.LabelsAdapter
	Line      string
}

A Record is an individual log record within the logs section.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳