record

package
v0.53.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 55

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 added in v0.46.0

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

Decode decodes a Histogram from a byte slice.

func DecodeHistogram added in v0.46.0

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

DecodeHistogram decodes a Histogram from a byte slice.

func EncodeFloatHistogram added in v0.46.0

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

EncodeFloatHistogram encodes the Float Histogram into a byte slice.

func EncodeHistogram added in v0.46.0

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

EncodeHistogram encodes a Histogram into a byte slice.

func EncodeLabels added in v0.38.0

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

EncodeLabels encodes the contents of labels into buf.

func GetMetricType added in v0.38.0

func GetMetricType(t model.MetricType) uint8

func ToMetricType added in v0.50.0

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 added in v0.51.0

func NewDecoder(t *labels.SymbolTable) Decoder

func (*Decoder) DecodeLabels added in v0.38.0

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 added in v0.42.0

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

func (*Decoder) HistogramSamples added in v0.40.0

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

func (*Decoder) Metadata added in v0.38.0

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

Metadata appends metadata in rec to the given slice.

func (*Decoder) MmapMarkers added in v0.39.0

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 added in v0.42.0

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

func (*Encoder) HistogramSamples added in v0.40.0

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

func (*Encoder) Metadata added in v0.38.0

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

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

func (*Encoder) MmapMarkers added in v0.39.0

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 added in v0.38.0

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 the labels, timestamp, value the exemplar was collected/observed with, and a reference to a series.

type RefFloatHistogramSample added in v0.42.0

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

RefFloatHistogramSample is a float histogram.

type RefHistogramSample added in v0.40.0

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

RefHistogramSample is a histogram.

type RefMetadata added in v0.38.0

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

RefMetadata is the metadata associated with a series ID.

type RefMmapMarker added in v0.39.0

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 added in v0.38.0

func (rt Type) String() string

Jump to

Keyboard shortcuts

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