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"` }
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 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