registry

package
v0.0.0-...-bfa2730 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CollectionInterval controls how often to collect metrics.
	// Defaults to 15s.
	CollectionInterval time.Duration `yaml:"collection_interval"`

	// StaleDuration controls how quickly series become stale and are deleted from the registry. An active
	// series is deleted if it hasn't been updated more stale duration.
	// Defaults to 15m.
	StaleDuration time.Duration `yaml:"stale_duration"`

	// ExternalLabels are added to any time series generated by this instance.
	ExternalLabels map[string]string `yaml:"external_labels,omitempty"`

	// MaxLabelNameLength configures the maximum length of label names. Label names exceeding
	// this limit will be truncated.
	MaxLabelNameLength int `yaml:"max_label_name_length"`

	// MaxLabelValueLength configures the maximum length of label values. Label values exceeding
	// this limit will be truncated.
	MaxLabelValueLength int `yaml:"max_label_value_length"`
}

func (*Config) RegisterFlagsAndApplyDefaults

func (cfg *Config) RegisterFlagsAndApplyDefaults(prefix string, f *flag.FlagSet)

RegisterFlagsAndApplyDefaults registers the flags.

type Counter

type Counter interface {
	Inc(values *LabelValues, value float64)
}

Counter https://prometheus.io/docs/concepts/metric_types/#counter

type Histogram

type Histogram interface {
	// ObserveWithExemplar observes a datapoint with the given values. traceID will be added as exemplar.
	ObserveWithExemplar(values *LabelValues, value float64, traceID string, multiplier float64)
}

Histogram https://prometheus.io/docs/concepts/metric_types/#histogram

type LabelValues

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

LabelValues is a wrapper around a slice of label values. It has the ability to cache the hash of the label values. When passing the same label values to multiple metrics, create LabelValues once and pass it to all of them.

type ManagedRegistry

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

func New

func New(cfg *Config, overrides Overrides, tenant string, appendable storage.Appendable, logger log.Logger) *ManagedRegistry

New creates a ManagedRegistry. This Registry will scrape itself, write samples into an appender and remove stale series.

func (*ManagedRegistry) Close

func (r *ManagedRegistry) Close()

func (*ManagedRegistry) NewCounter

func (r *ManagedRegistry) NewCounter(name string, labels []string) Counter

func (*ManagedRegistry) NewHistogram

func (r *ManagedRegistry) NewHistogram(name string, labels []string, buckets []float64) Histogram

func (*ManagedRegistry) NewLabelValues

func (r *ManagedRegistry) NewLabelValues(values []string) *LabelValues

type Overrides

type Overrides interface {
	MetricsGeneratorMaxActiveSeries(userID string) uint32
	MetricsGeneratorCollectionInterval(userID string) time.Duration
	MetricsGeneratorDisableCollection(userID string) bool
}

type Registry

type Registry interface {
	NewLabelValues(values []string) *LabelValues
	NewCounter(name string, labels []string) Counter
	NewHistogram(name string, labels []string, buckets []float64) Histogram
}

Registry is a metrics store.

type TestRegistry

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

TestRegistry is a simple implementation of Registry intended for tests. It is not concurrent-safe.

func NewTestRegistry

func NewTestRegistry() *TestRegistry

func (*TestRegistry) NewCounter

func (t *TestRegistry) NewCounter(name string, labels []string) Counter

func (*TestRegistry) NewHistogram

func (t *TestRegistry) NewHistogram(name string, labels []string, buckets []float64) Histogram

func (*TestRegistry) NewLabelValues

func (t *TestRegistry) NewLabelValues(values []string) *LabelValues

func (*TestRegistry) Query

func (t *TestRegistry) Query(name string, lbls labels.Labels) float64

Query returns the value of the given metric. Note this is a rather naive query engine, it's only possible to query metrics by using the exact same labels as they were stored with.

func (*TestRegistry) String

func (t *TestRegistry) String() string

Jump to

Keyboard shortcuts

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