types

package
v0.0.0-...-559914d Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AlloyFileVersionV1 = FileFormat("alloy.metrics.queue.v1")
View Source
const AlloyFileVersionV2 = FileFormat("alloy.metrics.queue.v2")
View Source
const PrometheusMetadataV1 = Type("prometheus.metadata.v1")

PrometheusMetadataV1 corresponds to prompb.MetricMetadata byte format.

View Source
const PrometheusMetricV1 = Type("prometheus.metric.v1")

PrometheusMetricV1 corresponds to prompb.TimeSeries byte format.

Variables

This section is empty.

Functions

func Zero

func Zero[T any]() T

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

type Callback

type Callback[T any, R any] struct {
	Value    T
	Response R
	// contains filtered or unexported fields
}

func (*Callback[T, R]) Notify

func (c *Callback[T, R]) Notify(response R, err error)

Notify must be called to return the synchronous call.

type CallbackHook

type CallbackHook[R any] interface {
	Notify(response R, err error)
}

type CategoryStats

type CategoryStats struct {
	RetriedSamples       int
	RetriedSamples429    int
	RetriedSamples5XX    int
	SeriesSent           int
	FailedSamples        int
	TTLDroppedSamples    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
	// Headers specifies the HTTP headers to be added to all requests
	// sent to the server.
	Headers map[string]string

	// ProxyURL is the URL of the HTTP proxy to use for requests.
	// If empty, no proxy is used.
	ProxyURL string
	// ProxyFromEnvironment determines whether to read proxy configuration from environment
	// variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY.
	// If true, environment proxy settings will be used even if ProxyURL is set.
	ProxyFromEnvironment bool
	// ProxyConnectHeaders specify the headers to send to proxies during CONNECT requests.
	ProxyConnectHeaders map[string]string

	// TLSCert is the PEM-encoded certificate string for TLS client authentication
	TLSCert string
	// TLSKey is the PEM-encoded private key string for TLS client authentication
	TLSKey string
	// TLSCACert is the PEM-encoded CA certificate string for server verification
	TLSCACert string
	// InsecureSkipVerify controls whether the client verifies the server's certificate chain and host name
	InsecureSkipVerify bool
	// UseRoundRobin
	UseRoundRobin bool
	// ParallelismConfig determines how many concurrent connections to have.
	Parallelism ParallelismConfig
}

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

func (ConnectionConfig) ToPrometheusConfig

func (cc ConnectionConfig) ToPrometheusConfig() (config.HTTPClientConfig, error)

ToPrometheusConfig converts a ConnectionConfig to a config.HTTPClientConfig and returns any error encountered

type Data

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

type DataHandle

type DataHandle struct {
	Pop  func() (map[string]string, []byte, error)
	Name string
}

type Datum

type Datum interface {
	// Bytes represents the underlying data and should only be used in conjunction with the type.
	Bytes() []byte
	Type() Type
	FileFormat() FileFormat
	// Free  datums are often pooled and this should be called when the datum is no longer needed.
	Free()
}

Datum represent one item of data.

type FileFormat

type FileFormat string

type FileStorage

type FileStorage interface {
	Start(ctx context.Context)
	Stop()
	Store(ctx context.Context, meta map[string]string, value []byte) error
}

type Mailbox

type Mailbox[T any] struct {
	// contains filtered or unexported fields
}

Mailbox is a backwards compatible implemention of the actor mailbox. It uses chann underneath the hood that mimics the behavior of actor mailboxes.

func NewMailbox

func NewMailbox[T any](opt ...chann.Opt) *Mailbox[T]

func (*Mailbox[T]) ReceiveC

func (m *Mailbox[T]) ReceiveC() <-chan T

func (*Mailbox[T]) Send

func (m *Mailbox[T]) Send(ctx context.Context, v T) error

type Marshaller

type Marshaller interface {

	// Marshal handler passes in the buffer to be written. The buffer is only valid for the lifecycle of the function call.
	// Metadata is passed via the map and should be encoded into the underlying storage. The same keys and values should be returned
	// on Deserialize.
	Marshal(handle func(map[string]string, []byte) error) error
}

Marshaller provides the ability to write for a given schema defined by the FileFormat. These are NOT threadsafe.

type MetadataDatum

type MetadataDatum interface {
	Datum
	IsMeta() bool
}

type MetricDatum

type MetricDatum interface {
	Datum
	Hash() uint64
	TimeStampMS() int64
	IsHistogram() bool
}

type NetworkClient

type NetworkClient interface {
	Start(ctx context.Context)
	Stop()
	// UpdateConfig is a synchronous call and will only return once the config
	// is applied or an error occurs.
	UpdateConfig(ctx context.Context, cfg ConnectionConfig) (bool, error)
}

type NetworkStats

type NetworkStats struct {
	Series                 CategoryStats
	Histogram              CategoryStats
	Metadata               CategoryStats
	SendDuration           time.Duration
	NewestTimestampSeconds 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 NotificationRelease

type NotificationRelease func()

type ParallelismConfig

type ParallelismConfig struct {
	// AllowedDrift is the maximum amount of time that is allowed for the Newest Timestamp Serializer - Newest Timestamp Sent via Network before the connections scales up.
	// If Newest TS In Serializer sees 100s and Newest TS Out Network sees 20s then we have a drift of 80s. If AllowedDrift is 60s that would
	// trigger a scaling up event.
	AllowedDrift time.Duration
	// MinimumScaleDownDrift is the amount if we go below that we can scale down. Using the above if In is 100s and Out is 70s and MinimumScaleDownDrift is 30 then we wont scale
	// down even though we are below the 60s. This is to keep the number of connections from flapping. In practice we should consider 30s MinimumScaleDownDrift and 60s AllowedDrift to be a sweet spot
	// for general usage.
	MinimumScaleDownDrift time.Duration
	// MaxConnections is the maximum number of concurrent connections to use.
	MaxConnections uint
	// MinConnections is the minimum number of concurrent connections to use.
	MinConnections uint
	// ResetInterval is how long to keep network successes and errors in memory for calculations.
	ResetInterval time.Duration
	// Lookback is how far to lookback for previous desired values. This is to prevent flapping.
	// In a situation where in the past 5 minutes you have desired [1,2,1,1] and desired is 1 it will
	// choose 2 since that was the greatest. This determines how fast you can scale down.
	Lookback time.Duration
	// CheckInterval is how long to check for desired values.
	CheckInterval time.Duration
	// AllowedNetworkErrorFraction is the fraction of failed network requests that are allowable. This will
	// trigger a decrease in connections if exceeded.
	AllowedNetworkErrorFraction float64
}

type ParralelismStats

type ParralelismStats struct {
	MinConnections     uint
	MaxConnections     uint
	DesiredConnections uint
}

type PrometheusMarshaller

type PrometheusMarshaller interface {
	Marshaller
	// AddPrometheusMetric adds a metric to the list of metrics. External Labels are passed in and added to the raw byte representation.
	// They are not added to lbls since that array may not be owned by the caller. Metric labels will override external labels.
	AddPrometheusMetric(ts int64, value float64, lbls labels.Labels, h *histogram.Histogram, fh *histogram.FloatHistogram, e exemplar.Exemplar, externalLabels map[string]string) error
	AddPrometheusMetadata(name string, unit string, help string, pType string) error
}

type PrometheusMetric

type PrometheusMetric struct {
	H  *histogram.Histogram
	FH *histogram.FloatHistogram
	L  labels.Labels
	E  exemplar.Exemplar
	T  int64
	V  float64
}

type PrometheusSerializer

type PrometheusSerializer interface {
	Serializer
	SendMetrics(ctx context.Context, metrics []*PrometheusMetric, externalLabels map[string]string) error
	SendMetadata(ctx context.Context, name string, unit string, help string, pType string) error
}

type RequestMoreSignals

type RequestMoreSignals[T Datum] struct {
	Response chan []T
}

type Serializer

type Serializer interface {
	Start(ctx context.Context) error
	Stop()
	UpdateConfig(ctx context.Context, cfg SerializerConfig) (bool, 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
	ExemplarsStored          int
	MetadataStored           int
	Errors                   int
	NewestTimestampSeconds   int64
	TTLDropped               int
	UncompressedBytesWritten int
	CompressedBytesWritten   int
	FileIDWritten            int
	UncompressedBytesRead    int
	CompressedBytesRead      int
	FileIDRead               int
}

type StatsHub

type StatsHub interface {
	SendSeriesNetworkStats(NetworkStats)
	SendSerializerStats(SerializerStats)
	SendMetadataNetworkStats(NetworkStats)
	SendParralelismStats(stats ParralelismStats)

	RegisterSeriesNetwork(func(NetworkStats)) NotificationRelease
	RegisterMetadataNetwork(func(NetworkStats)) NotificationRelease
	RegisterSerializer(func(SerializerStats)) NotificationRelease
	RegisterParralelism(func(ParralelismStats)) NotificationRelease
}

StatsHub allows types to register to receive stats and to also send stats to fanout to receivers.

type SyncMailbox

type SyncMailbox[T, R any] struct {
	// contains filtered or unexported fields
}

SyncMailbox is used to synchronously send data, and wait for it to process before returning.

func NewSyncMailbox

func NewSyncMailbox[T, R any](opt ...chann.Opt) *SyncMailbox[T, R]

func (*SyncMailbox[T, R]) ReceiveC

func (sm *SyncMailbox[T, R]) ReceiveC() <-chan *Callback[T, R]

func (*SyncMailbox[T, R]) Send

func (sm *SyncMailbox[T, R]) Send(ctx gocontext.Context, value T) (R, error)

type Type

type Type string

type Unmarshaller

type Unmarshaller interface {
	// Unmarshal is called to create a list of datums.
	// Metadata will be passed via the map.
	// The buffer passed in is SAFE for reuse/unsafe strings.
	Unmarshal(map[string]string, []byte) (items []Datum, err error)
}

Unmarshaller allows reading of a given FileFormat.

Directories

Path Synopsis
Package v2 Copied from prometheus.
Package v2 Copied from prometheus.

Jump to

Keyboard shortcuts

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