prometheus

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamText    expfmt.Format = expfmt.FmtText
	StreamCompact expfmt.Format = expfmt.FmtProtoCompact
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter tracks monotonically increasing value.

func (Counter) Add

func (c Counter) Add(delta int64)

Add adds delta to the counter. Delta must be >=0.

func (Counter) Inc

func (c Counter) Inc()

Inc increments counter by 1.

type CounterVec

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

CounterVec wraps prometheus.CounterVec and implements metrics.CounterVec interface.

func (*CounterVec) Reset

func (v *CounterVec) Reset()

Reset deletes all metrics in this vector.

func (*CounterVec) With

func (v *CounterVec) With(tags map[string]string) metrics.Counter

With creates new or returns existing counter with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type DurationHistogramVec

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

DurationHistogramVec wraps prometheus.HistogramVec and implements metrics.TimerVec interface.

func (*DurationHistogramVec) Reset

func (v *DurationHistogramVec) Reset()

Reset deletes all metrics in this vector.

func (*DurationHistogramVec) With

func (v *DurationHistogramVec) With(tags map[string]string) metrics.Timer

With creates new or returns existing duration histogram with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type FuncCounter

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

func (FuncCounter) Function

func (c FuncCounter) Function() func() int64

type FuncGauge

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

func (FuncGauge) Function

func (g FuncGauge) Function() func() float64

type FuncIntGauge

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

func (FuncIntGauge) Function

func (g FuncIntGauge) Function() func() int64

type Gauge

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

Gauge tracks single float64 value.

func (Gauge) Add

func (g Gauge) Add(value float64)

func (Gauge) Set

func (g Gauge) Set(value float64)

type GaugeVec

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

GaugeVec wraps prometheus.GaugeVec and implements metrics.GaugeVec interface.

func (*GaugeVec) Reset

func (v *GaugeVec) Reset()

Reset deletes all metrics in this vector.

func (*GaugeVec) With

func (v *GaugeVec) With(tags map[string]string) metrics.Gauge

With creates new or returns existing gauge with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type Histogram

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

func (Histogram) RecordDuration

func (h Histogram) RecordDuration(value time.Duration)

func (Histogram) RecordValue

func (h Histogram) RecordValue(value float64)

type HistogramVec

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

HistogramVec wraps prometheus.HistogramVec and implements metrics.HistogramVec interface.

func (*HistogramVec) Reset

func (v *HistogramVec) Reset()

Reset deletes all metrics in this vector.

func (*HistogramVec) With

func (v *HistogramVec) With(tags map[string]string) metrics.Histogram

With creates new or returns existing histogram with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type IntGauge

type IntGauge struct {
	metrics.Gauge
}

IntGauge tracks single int64 value.

func (IntGauge) Add

func (i IntGauge) Add(value int64)

func (IntGauge) Set

func (i IntGauge) Set(value int64)

type IntGaugeVec

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

IntGaugeVec wraps prometheus.GaugeVec and implements metrics.IntGaugeVec interface.

func (*IntGaugeVec) Reset

func (v *IntGaugeVec) Reset()

Reset deletes all metrics in this vector.

func (*IntGaugeVec) With

func (v *IntGaugeVec) With(tags map[string]string) metrics.IntGauge

With creates new or returns existing gauge with given tags from vector. It will panic if tags keys set is not equal to vector labels.

type PrometheusRegistry

type PrometheusRegistry interface {
	prometheus.Registerer
	prometheus.Gatherer
}

type Registry

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

func NewRegistry

func NewRegistry(opts *RegistryOpts) *Registry

NewRegistry creates new Prometheus backed registry.

func (Registry) ComposeName

func (r Registry) ComposeName(parts ...string) string

ComposeName builds FQ name with appropriate separator.

func (Registry) Counter

func (r Registry) Counter(name string) metrics.Counter

func (*Registry) CounterVec

func (r *Registry) CounterVec(name string, labels []string) metrics.CounterVec

CounterVec creates a new counters vector with given metric name and partitioned by the given label names.

func (Registry) DurationHistogram

func (r Registry) DurationHistogram(name string, buckets metrics.DurationBuckets) metrics.Timer

func (*Registry) DurationHistogramVec

func (r *Registry) DurationHistogramVec(name string, buckets metrics.DurationBuckets, labels []string) metrics.TimerVec

DurationHistogramVec creates a new duration histograms vector with given metric name and buckets and partitioned by the given label names.

func (Registry) FuncCounter

func (r Registry) FuncCounter(name string, function func() int64) metrics.FuncCounter

func (Registry) FuncGauge

func (r Registry) FuncGauge(name string, function func() float64) metrics.FuncGauge

func (Registry) FuncIntGauge

func (r Registry) FuncIntGauge(name string, function func() int64) metrics.FuncIntGauge

func (Registry) Gather

func (r Registry) Gather() ([]*dto.MetricFamily, error)

Gather returns raw collected Prometheus metrics.

func (Registry) Gauge

func (r Registry) Gauge(name string) metrics.Gauge

func (*Registry) GaugeVec

func (r *Registry) GaugeVec(name string, labels []string) metrics.GaugeVec

GaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.

func (Registry) Histogram

func (r Registry) Histogram(name string, buckets metrics.Buckets) metrics.Histogram

func (*Registry) HistogramVec

func (r *Registry) HistogramVec(name string, buckets metrics.Buckets, labels []string) metrics.HistogramVec

HistogramVec creates a new histograms vector with given metric name and buckets and partitioned by the given label names.

func (Registry) IntGauge

func (r Registry) IntGauge(name string) metrics.IntGauge

func (*Registry) IntGaugeVec

func (r *Registry) IntGaugeVec(name string, labels []string) metrics.IntGaugeVec

IntGaugeVec creates a new gauges vector with given metric name and partitioned by the given label names.

func (*Registry) Stream

func (r *Registry) Stream(_ context.Context, w io.Writer) (int, error)

func (Registry) Timer

func (r Registry) Timer(name string) metrics.Timer

func (*Registry) TimerVec

func (r *Registry) TimerVec(name string, labels []string) metrics.TimerVec

TimerVec creates a new timers vector with given metric name and partitioned by the given label names.

func (Registry) WithPrefix

func (r Registry) WithPrefix(prefix string) metrics.Registry

WithPrefix creates new sub-scope, where each metric has prefix added to it name.

func (Registry) WithTags

func (r Registry) WithTags(tags map[string]string) metrics.Registry

WithTags creates new sub-scope, where each metric has tags attached to it.

type RegistryOpts

type RegistryOpts struct {
	Prefix string
	Tags   map[string]string

	Collectors    []func(metrics.Registry)
	NameSanitizer func(string) string
	StreamFormat  expfmt.Format
	// contains filtered or unexported fields
}

func NewRegistryOpts

func NewRegistryOpts() *RegistryOpts

NewRegistryOpts returns new initialized instance of RegistryOpts.

func (*RegistryOpts) AddCollectors

func (o *RegistryOpts) AddCollectors(
	ctx context.Context, c metrics.CollectPolicy, collectors ...collect.Func,
) *RegistryOpts

AddCollectors adds collectors that handle their metrics automatically (e.g. system metrics).

func (*RegistryOpts) AddTags

func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts

AddTags merges given tags with existing.

func (*RegistryOpts) AppendPrefix

func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts

AppendPrefix adds given prefix as postfix to existing using separator.

func (*RegistryOpts) SetNameSanitizer

func (o *RegistryOpts) SetNameSanitizer(v func(string) string) *RegistryOpts

SetNameSanitizer sets a functions which will be called for each metric's name. It allows to alter names, for example to replace invalid characters

func (*RegistryOpts) SetPrefix

func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts

SetPrefix overrides existing prefix.

func (*RegistryOpts) SetRegistry

func (o *RegistryOpts) SetRegistry(rg PrometheusRegistry) *RegistryOpts

SetRegistry sets the given prometheus registry for further usage instead of creating a new one.

This is primarily used to unite externally defined metrics with metrics kept in the core registry.

func (*RegistryOpts) SetStreamFormat

func (o *RegistryOpts) SetStreamFormat(format expfmt.Format) *RegistryOpts

SetStreamFormat sets default metrics stream format

func (*RegistryOpts) SetTags

func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts

SetTags overrides existing tags.

type Timer

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

Timer measures gauge duration.

func (Timer) RecordDuration

func (t Timer) RecordDuration(value time.Duration)

type TimerVec

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

TimerVec wraps prometheus.GaugeVec and implements metrics.TimerVec interface.

func (*TimerVec) Reset

func (v *TimerVec) Reset()

Reset deletes all metrics in this vector.

func (*TimerVec) With

func (v *TimerVec) With(tags map[string]string) metrics.Timer

With creates new or returns existing timer with given tags from vector. It will panic if tags keys set is not equal to vector labels.

Jump to

Keyboard shortcuts

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