batch

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Streams   map[string]*Stream
	Bytes     int
	CreatedAt time.Time
	// contains filtered or unexported fields
}

Batch holds pending logs waiting to be sent to Loki. The aggregation of the logs is used to reduce the number of push request to the Loki

func NewBatch

func NewBatch(id uint64) *Batch

NewBatch returns a batch where the label set<ls>, timestamp<t> and the log line<line> are added to it.

func (*Batch) Add

func (b *Batch) Add(ls model.LabelSet, t time.Time, line string)

Add an entry to the batch

func (*Batch) Age

func (b *Batch) Age() time.Duration

Age of the batch since its creation

func (*Batch) SizeBytes

func (b *Batch) SizeBytes() int

SizeBytes returns the current batch size in bytes

func (*Batch) SizeBytesAfter

func (b *Batch) SizeBytesAfter(line string) int

SizeBytesAfter returns the size of the batch after the log of the next entry is added

func (*Batch) Sort

func (b *Batch) Sort()

Sort sorts the entries in each stream by the timestamp

type Entry

type Entry struct {
	Timestamp time.Time
	Line      string
}

Entry is a log entry with a timestamp.

type Stream

type Stream struct {
	Labels  model.LabelSet
	Entries []Entry
	// contains filtered or unexported fields
}

Stream contains a unique labels set as a string and a set of entries for it. We are not using the proto generated version but this custom one so that we can improve serialization see benchmark.

Jump to

Keyboard shortcuts

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