types

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: 8 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
	// Connections is the number of concurrent connections to use for sending data.
	Connections uint
	// 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
}

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

func (ConnectionConfig) ToPrometheusConfig

func (cc ConnectionConfig) ToPrometheusConfig() config.HTTPClientConfig

ToPrometheusConfig converts a ConnectionConfig to a config.HTTPClientConfig

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 Datum

type Datum interface {
	// Bytes represents the underlying data and should only be used in conjuction 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()
	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]) Close

func (m *Mailbox[T]) Close()

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()
	// SendSeries will block if the network caches are full.
	SendSeries(ctx context.Context, d MetricDatum) error
	// SendMetadata will block if the network caches are full.
	SendMetadata(ctx context.Context, d MetadataDatum) 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) (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 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, externalLabels map[string]string) error
	AddPrometheusMetadata(name string, unit string, help string, pType string) error
}

type PrometheusSerializer

type PrometheusSerializer interface {
	Serializer
	SendMetric(ctx context.Context, l labels.Labels, t int64, v float64, h *histogram.Histogram, fh *histogram.FloatHistogram, externalLabels map[string]string) error
	SendMetadata(ctx context.Context, name string, unit string, help string, pType string) error
}

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
	MetadataStored         int
	Errors                 int
	NewestTimestampSeconds int64
	TTLDropped             int
}

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](opts ...actor.MailboxOption) *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)

func (*SyncMailbox[T, R]) Start

func (sm *SyncMailbox[T, R]) Start()

func (*SyncMailbox[T, R]) Stop

func (sm *SyncMailbox[T, R]) Stop()

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
Copied from prometheus.
Copied from prometheus.

Jump to

Keyboard shortcuts

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