record

package
v0.0.0-...-bec5d16 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package record contains the various record types used for encoding various Head block data in the WAL and in-memory snapshot.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned if a looked up resource was not found. Duplicate ErrNotFound from head.go.

Functions

func DecodeFloatHistogram

func DecodeFloatHistogram(buf *encoding.Decbuf, fh *histogram.FloatHistogram)

Decode decodes a Histogram from a byte slice.

func DecodeHistogram

func DecodeHistogram(buf *encoding.Decbuf, h *histogram.Histogram)

DecodeHistogram decodes a Histogram from a byte slice.

func EncodeFloatHistogram

func EncodeFloatHistogram(buf *encoding.Encbuf, h *histogram.FloatHistogram)

Encode encodes the Float Histogram into a byte slice.

func EncodeHistogram

func EncodeHistogram(buf *encoding.Encbuf, h *histogram.Histogram)

EncodeHistogram encodes a Histogram into a byte slice.

func EncodeLabels

func EncodeLabels(buf *encoding.Encbuf, lbls labels.Labels)

EncodeLabels encodes the contents of labels into buf.

func GetMetricType

func GetMetricType(t model.MetricType) uint8

func ToMetricType

func ToMetricType(m uint8) model.MetricType

Types

type Decoder

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

Decoder decodes series, sample, metadata and tombstone records.

func NewDecoder

func NewDecoder(t *labels.SymbolTable) Decoder

func (*Decoder) DecodeLabels

func (d *Decoder) DecodeLabels(dec *encoding.Decbuf) labels.Labels

DecodeLabels decodes one set of labels from buf.

func (*Decoder) Exemplars

func (d *Decoder) Exemplars(rec []byte, exemplars []RefExemplar) ([]RefExemplar, error)

func (*Decoder) ExemplarsFromBuffer

func (d *Decoder) ExemplarsFromBuffer(dec *encoding.Decbuf, exemplars []RefExemplar) ([]RefExemplar, error)

func (*Decoder) FloatHistogramSamples

func (d *Decoder) FloatHistogramSamples(rec []byte, histograms []RefFloatHistogramSample) ([]RefFloatHistogramSample, error)

func (*Decoder) HistogramSamples

func (d *Decoder) HistogramSamples(rec []byte, histograms []RefHistogramSample) ([]RefHistogramSample, error)

func (*Decoder) Metadata

func (d *Decoder) Metadata(rec []byte, metadata []RefMetadata) ([]RefMetadata, error)

Metadata appends metadata in rec to the given slice.

func (*Decoder) MmapMarkers

func (d *Decoder) MmapMarkers(rec []byte, markers []RefMmapMarker) ([]RefMmapMarker, error)

func (*Decoder) Samples

func (d *Decoder) Samples(rec []byte, samples []RefSample) ([]RefSample, error)

Samples appends samples in rec to the given slice.

func (*Decoder) Series

func (d *Decoder) Series(rec []byte, series []RefSeries) ([]RefSeries, error)

Series appends series in rec to the given slice.

func (*Decoder) Tombstones

func (d *Decoder) Tombstones(rec []byte, tstones []tombstones.Stone) ([]tombstones.Stone, error)

Tombstones appends tombstones in rec to the given slice.

func (*Decoder) Type

func (d *Decoder) Type(rec []byte) Type

Type returns the type of the record. Returns RecordUnknown if no valid record type is found.

type Encoder

type Encoder struct{}

Encoder encodes series, sample, and tombstones records. The zero value is ready to use.

func (*Encoder) EncodeExemplarsIntoBuffer

func (e *Encoder) EncodeExemplarsIntoBuffer(exemplars []RefExemplar, buf *encoding.Encbuf)

func (*Encoder) Exemplars

func (e *Encoder) Exemplars(exemplars []RefExemplar, b []byte) []byte

func (*Encoder) FloatHistogramSamples

func (e *Encoder) FloatHistogramSamples(histograms []RefFloatHistogramSample, b []byte) []byte

func (*Encoder) HistogramSamples

func (e *Encoder) HistogramSamples(histograms []RefHistogramSample, b []byte) []byte

func (*Encoder) Metadata

func (e *Encoder) Metadata(metadata []RefMetadata, b []byte) []byte

Metadata appends the encoded metadata to b and returns the resulting slice.

func (*Encoder) MmapMarkers

func (e *Encoder) MmapMarkers(markers []RefMmapMarker, b []byte) []byte

func (*Encoder) Samples

func (e *Encoder) Samples(samples []RefSample, b []byte) []byte

Samples appends the encoded samples to b and returns the resulting slice.

func (*Encoder) Series

func (e *Encoder) Series(series []RefSeries, b []byte) []byte

Series appends the encoded series to b and returns the resulting slice.

func (*Encoder) Tombstones

func (e *Encoder) Tombstones(tstones []tombstones.Stone, b []byte) []byte

Tombstones appends the encoded tombstones to b and returns the resulting slice.

type MetricType

type MetricType uint8

MetricType represents the type of a series.

const (
	UnknownMT       MetricType = 0
	Counter         MetricType = 1
	Gauge           MetricType = 2
	HistogramSample MetricType = 3
	GaugeHistogram  MetricType = 4
	Summary         MetricType = 5
	Info            MetricType = 6
	Stateset        MetricType = 7
)

type RefExemplar

type RefExemplar struct {
	Ref    chunks.HeadSeriesRef
	T      int64
	V      float64
	Labels labels.Labels
}

RefExemplar is an exemplar with it's labels, timestamp, value the exemplar was collected/observed with, and a reference to a series.

type RefFloatHistogramSample

type RefFloatHistogramSample struct {
	Ref chunks.HeadSeriesRef
	T   int64
	FH  *histogram.FloatHistogram
}

RefFloatHistogramSample is a float histogram.

type RefHistogramSample

type RefHistogramSample struct {
	Ref chunks.HeadSeriesRef
	T   int64
	H   *histogram.Histogram
}

RefHistogramSample is a histogram.

type RefMetadata

type RefMetadata struct {
	Ref  chunks.HeadSeriesRef
	Type uint8
	Unit string
	Help string
}

RefMetadata is the metadata associated with a series ID.

type RefMmapMarker

type RefMmapMarker struct {
	Ref     chunks.HeadSeriesRef
	MmapRef chunks.ChunkDiskMapperRef
}

RefMmapMarker marks that the all the samples of the given series until now have been m-mapped to disk.

type RefSample

type RefSample struct {
	Ref chunks.HeadSeriesRef
	T   int64
	V   float64
}

RefSample is a timestamp/value pair associated with a reference to a series. TODO(beorn7): Perhaps make this "polymorphic", including histogram and float-histogram pointers? Then get rid of RefHistogramSample.

type RefSeries

type RefSeries struct {
	Ref    chunks.HeadSeriesRef
	Labels labels.Labels
}

RefSeries is the series labels with the series ID.

type Type

type Type uint8

Type represents the data type of a record.

const (
	// Unknown is returned for unrecognised WAL record types.
	Unknown Type = 255
	// Series is used to match WAL records of type Series.
	Series Type = 1
	// Samples is used to match WAL records of type Samples.
	Samples Type = 2
	// Tombstones is used to match WAL records of type Tombstones.
	Tombstones Type = 3
	// Exemplars is used to match WAL records of type Exemplars.
	Exemplars Type = 4
	// MmapMarkers is used to match OOO WBL records of type MmapMarkers.
	MmapMarkers Type = 5
	// Metadata is used to match WAL records of type Metadata.
	Metadata Type = 6
	// HistogramSamples is used to match WAL records of type Histograms.
	HistogramSamples Type = 7
	// FloatHistogramSamples is used to match WAL records of type Float Histograms.
	FloatHistogramSamples Type = 8
)

func (Type) String

func (rt Type) String() string

Jump to

Keyboard shortcuts

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