v1

package
v0.0.0-...-4d13735 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MetaHelp = "__alloy_metadata_help__"
View Source
const MetaType = "__alloy_metadata_type__"
View Source
const MetaUnit = "__alloy_metadata_unit__"

Variables

View Source
var OutStandingTimeSeriesBinary = atomic.Int32{}

Functions

func DeserializeToSeriesGroup

func DeserializeToSeriesGroup(sg *SeriesGroup, buf []byte) ([]types.Datum, error)

DeserializeToSeriesGroup transforms a buffer to a SeriesGroup and converts the stringmap + indexes into actual Labels.

func PutTimeSeriesIntoPool

func PutTimeSeriesIntoPool(ts *TimeSeriesBinary)

func PutTimeSeriesSliceIntoPool

func PutTimeSeriesSliceIntoPool(tss []*TimeSeriesBinary)

func ToPromBucketSpans

func ToPromBucketSpans(bss []BucketSpan) []prompb.BucketSpan

Types

type BucketSpan

type BucketSpan struct {
	Offset int32
	Length uint32
}

func FromPromSpan

func FromPromSpan(spans []histogram.Span) []BucketSpan

func (*BucketSpan) DecodeMsg

func (z *BucketSpan) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (BucketSpan) EncodeMsg

func (z BucketSpan) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (BucketSpan) MarshalMsg

func (z BucketSpan) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (BucketSpan) Msgsize

func (z BucketSpan) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*BucketSpan) ToPromBucketSpan

func (bs *BucketSpan) ToPromBucketSpan() prompb.BucketSpan

func (*BucketSpan) UnmarshalMsg

func (z *BucketSpan) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ByteString

type ByteString []byte

func (*ByteString) DecodeMsg

func (z *ByteString) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (ByteString) EncodeMsg

func (z ByteString) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (ByteString) MarshalMsg

func (z ByteString) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (ByteString) Msgsize

func (z ByteString) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (ByteString) String

func (v ByteString) String() string

String returns the underlying bytes as a string without copying. This is a huge performance win with no side effect as long as the underlying byte slice is not reused. In this case it is not.

func (*ByteString) UnmarshalMsg

func (v *ByteString) UnmarshalMsg(bts []byte) (o []byte, err error)

type FloatHistogram

type FloatHistogram struct {
	Count                HistogramCount
	Sum                  float64
	Schema               int32
	ZeroThreshold        float64
	ZeroCount            HistogramZeroCount
	NegativeSpans        []BucketSpan
	NegativeDeltas       []int64
	NegativeCounts       []float64
	PositiveSpans        []BucketSpan
	PositiveDeltas       []int64
	PositiveCounts       []float64
	ResetHint            int32
	TimestampMillisecond int64
}

func (*FloatHistogram) DecodeMsg

func (z *FloatHistogram) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*FloatHistogram) EncodeMsg

func (z *FloatHistogram) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*FloatHistogram) MarshalMsg

func (z *FloatHistogram) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*FloatHistogram) Msgsize

func (z *FloatHistogram) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*FloatHistogram) ToPromFloatHistogram

func (h *FloatHistogram) ToPromFloatHistogram() prompb.Histogram

func (*FloatHistogram) UnmarshalMsg

func (z *FloatHistogram) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Histogram

type Histogram struct {
	Count                HistogramCount
	Sum                  float64
	Schema               int32
	ZeroThreshold        float64
	ZeroCount            HistogramZeroCount
	NegativeSpans        []BucketSpan
	NegativeBuckets      []int64
	NegativeCounts       []float64
	PositiveSpans        []BucketSpan
	PositiveBuckets      []int64
	PositiveCounts       []float64
	ResetHint            int32
	TimestampMillisecond int64
}

func (*Histogram) DecodeMsg

func (z *Histogram) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Histogram) EncodeMsg

func (z *Histogram) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Histogram) MarshalMsg

func (z *Histogram) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Histogram) Msgsize

func (z *Histogram) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Histogram) ToPromHistogram

func (h *Histogram) ToPromHistogram() prompb.Histogram

func (*Histogram) UnmarshalMsg

func (z *Histogram) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type HistogramCount

type HistogramCount struct {
	IsInt      bool
	IntValue   uint64
	FloatValue float64
}

func (*HistogramCount) DecodeMsg

func (z *HistogramCount) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (HistogramCount) EncodeMsg

func (z HistogramCount) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (HistogramCount) MarshalMsg

func (z HistogramCount) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (HistogramCount) Msgsize

func (z HistogramCount) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*HistogramCount) UnmarshalMsg

func (z *HistogramCount) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type HistogramZeroCount

type HistogramZeroCount struct {
	IsInt      bool
	IntValue   uint64
	FloatValue float64
}

func (*HistogramZeroCount) DecodeMsg

func (z *HistogramZeroCount) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (HistogramZeroCount) EncodeMsg

func (z HistogramZeroCount) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (HistogramZeroCount) MarshalMsg

func (z HistogramZeroCount) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (HistogramZeroCount) Msgsize

func (z HistogramZeroCount) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*HistogramZeroCount) UnmarshalMsg

func (z *HistogramZeroCount) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Histograms

type Histograms struct {
	Histogram      *Histogram
	FloatHistogram *FloatHistogram
}

func (*Histograms) DecodeMsg

func (z *Histograms) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Histograms) EncodeMsg

func (z *Histograms) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Histograms) MarshalMsg

func (z *Histograms) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Histograms) Msgsize

func (z *Histograms) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Histograms) UnmarshalMsg

func (z *Histograms) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type LabelHandle

type LabelHandle struct {
	Name  unique.Handle[string]
	Value unique.Handle[string]
}

type LabelHandles

type LabelHandles []LabelHandle

func (LabelHandles) Get

func (lh LabelHandles) Get(name string) string

func (LabelHandles) Has

func (lh LabelHandles) Has(name string) bool

type Serialization

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

func GetSerializer

func GetSerializer() *Serialization

func (*Serialization) AddPrometheusMetadata

func (s *Serialization) AddPrometheusMetadata(name string, unit string, help string, pType string) error

func (*Serialization) AddPrometheusMetric

func (s *Serialization) AddPrometheusMetric(ts int64, value float64, lbls labels.Labels, h *histogram.Histogram, fh *histogram.FloatHistogram, _ map[string]string) error

func (*Serialization) Marshal

func (s *Serialization) Marshal(handle func(map[string]string, []byte) error) error

func (*Serialization) Unmarshal

func (s *Serialization) Unmarshal(_ map[string]string, buf []byte) (items []types.Datum, err error)

type SeriesGroup

type SeriesGroup struct {
	Strings  []ByteString
	Series   []*TimeSeriesBinary
	Metadata []*TimeSeriesBinary
}

SeriesGroup is the holder for TimeSeries, Metadata, and the strings array. When serialized the Labels Key,Value array will be transformed into LabelNames and LabelsValues that point to the index in Strings. This deduplicates the strings and decreases the size on disk.

func (*SeriesGroup) DecodeMsg

func (z *SeriesGroup) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*SeriesGroup) EncodeMsg

func (z *SeriesGroup) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*SeriesGroup) MarshalMsg

func (z *SeriesGroup) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*SeriesGroup) Msgsize

func (z *SeriesGroup) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*SeriesGroup) UnmarshalMsg

func (z *SeriesGroup) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TimeSeriesBinary

type TimeSeriesBinary struct {
	// Labels are not serialized to msgp, instead we store separately a dictionary of strings and use `LabelNames` and `LabelValues` to refer to the dictionary by ID.
	LabelsNames  []uint32
	LabelsValues []uint32
	// TS is unix milliseconds.
	TS         int64
	Value      float64
	Hash       uint64
	Histograms Histograms
}

TimeSeriesBinary is an optimized format for handling metrics and metadata. It should never be instantiated directly but instead use GetTimeSeriesFromPool and PutTimeSeriesSliceIntoPool. This allows us to reuse these objects and avoid allocations.

func GetTimeSeriesFromPool

func GetTimeSeriesFromPool() *TimeSeriesBinary

func (*TimeSeriesBinary) DecodeMsg

func (z *TimeSeriesBinary) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*TimeSeriesBinary) EncodeMsg

func (z *TimeSeriesBinary) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*TimeSeriesBinary) FromFloatHistogram

func (ts *TimeSeriesBinary) FromFloatHistogram(timestamp int64, h *histogram.FloatHistogram)

func (*TimeSeriesBinary) FromHistogram

func (ts *TimeSeriesBinary) FromHistogram(timestamp int64, h *histogram.Histogram)

func (*TimeSeriesBinary) MarshalMsg

func (z *TimeSeriesBinary) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*TimeSeriesBinary) Msgsize

func (z *TimeSeriesBinary) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TimeSeriesBinary) UnmarshalMsg

func (z *TimeSeriesBinary) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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