types

package
v2.0.0-...-95fa716 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AlloyFileVersion = "alloy.metrics.queue.v1"
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 PutTimeSeriesIntoPool

func PutTimeSeriesIntoPool(ts *TimeSeriesBinary)

func PutTimeSeriesSliceIntoPool

func PutTimeSeriesSliceIntoPool(tss []*TimeSeriesBinary)

func ToPromBucketSpans

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

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

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 CategoryStats

type CategoryStats struct {
	RetriedSamples       int
	RetriedSamples429    int
	RetriedSamples5XX    int
	SeriesSent           int
	FailedSamples        int
	NetworkSamplesFailed int
}

type ConnectionConfig

type ConnectionConfig struct {
	// URL is the URL of the Prometheus server.
	URL string
	// BasicAuth holds the username and password for basic HTTP authentication.
	BasicAuth *BasicAuth
	// BearerToken is the bearer token for the Prometheus server.
	BearerToken string
	// UserAgent is the User-Agent header sent to the Prometheus server.
	UserAgent string
	// Timeout specifies the duration for which the connection will wait for a response before timing out.
	Timeout time.Duration
	// RetryBackoff is the duration between retries when a network request fails.
	// The next retry will happen after RetryBackoff + (RetryBackoff * attempt number).
	RetryBackoff time.Duration
	// MaxRetryAttempts specifies the maximum number of times a request will be retried
	// if it fails. The next retry will happen after RetryBackoff + (RetryBackoff * attempt number).
	// If this is set to 0, no retries are attempted.
	MaxRetryAttempts uint
	// BatchCount is the number of time series to batch together before sending to the network.
	BatchCount int
	// FlushInterval specifies the duration between each flush of the network
	// buffer. If no data is available, the buffer is not flushed.
	FlushInterval time.Duration
	// ExternalLabels specifies the external labels to be added to all samples
	// sent to the Prometheus server.
	ExternalLabels map[string]string
	// Connections is the number of concurrent connections to use for sending data.
	Connections uint
}

ConnectionConfig holds configuration details for network connections. It includes various options such as authentication, timeouts, retry policies, batching, and connection management settings.

func (ConnectionConfig) Equals

func (cc ConnectionConfig) Equals(bb ConnectionConfig) bool

type Data

type Data struct {
	Meta map[string]string
	Data []byte
}

type DataHandle

type DataHandle struct {
	Name string
	// Pop will get the data and delete the source of the data.
	Pop func() (map[string]string, []byte, error)
}

type FileStorage

type FileStorage interface {
	Start()
	Stop()
	Store(ctx context.Context, meta map[string]string, value []byte) 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 NetworkClient

type NetworkClient interface {
	Start()
	Stop()
	// SendSeries will block if the network caches are full.
	SendSeries(ctx context.Context, d *TimeSeriesBinary) error
	// SendMetadata will block if the network caches are full.
	SendMetadata(ctx context.Context, d *TimeSeriesBinary) error
	// UpdateConfig is a synchronous call and will only return once the config
	// is applied or an error occurs.
	UpdateConfig(ctx context.Context, cfg ConnectionConfig) error
}

type NetworkStats

type NetworkStats struct {
	Series          CategoryStats
	Histogram       CategoryStats
	Metadata        CategoryStats
	SendDuration    time.Duration
	NewestTimestamp int64
	SeriesBytes     int
	MetadataBytes   int
}

func (NetworkStats) Total429

func (ns NetworkStats) Total429() int

func (NetworkStats) Total5XX

func (ns NetworkStats) Total5XX() int

func (NetworkStats) TotalFailed

func (ns NetworkStats) TotalFailed() int

func (NetworkStats) TotalRetried

func (ns NetworkStats) TotalRetried() int

func (NetworkStats) TotalSent

func (ns NetworkStats) TotalSent() int

type Serializer

type Serializer interface {
	Start()
	Stop()
	SendSeries(ctx context.Context, data *TimeSeriesBinary) error
	SendMetadata(ctx context.Context, data *TimeSeriesBinary) error
	UpdateConfig(ctx context.Context, cfg SerializerConfig) error
}

Serializer handles converting a set of signals into a binary representation to be written to storage.

type SerializerConfig

type SerializerConfig struct {
	// MaxSignalsInBatch controls what the max batch size is.
	MaxSignalsInBatch uint32
	// FlushFrequency controls how often to write to disk regardless of MaxSignalsInBatch.
	FlushFrequency time.Duration
}

type SerializerStats

type SerializerStats struct {
	SeriesStored    int
	MetadataStored  int
	Errors          int
	NewestTimestamp int64
}

type SeriesGroup

type SeriesGroup struct {
	Strings  []string
	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 DeserializeToSeriesGroup

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

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

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.
	Labels       labels.Labels `msg:"-"`
	LabelsNames  []uint32
	LabelsValues []uint32
	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) FillLabelMapping

func (ts *TimeSeriesBinary) FillLabelMapping(strMapToInt map[string]uint32)

FillLabelMapping is what does the conversion from labels.Labels to LabelNames and LabelValues while filling in the string map, that is later converted to []string.

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) IsMetadata

func (ts TimeSeriesBinary) IsMetadata() bool

IsMetadata is used because it's easier to store metadata as a set of labels.

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