registry

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 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"`
}

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

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.

func NewLabelValues

func NewLabelValues(values []string) *LabelValues

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

type Overrides

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

type Registry

type Registry interface {
	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) 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