metrics

package
v0.0.0-...-ff78b6e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnabledExpensive = false

Functions

func Setup

func Setup(address string, logger log.Logger) *http.ServeMux

Setup starts a dedicated metrics server at the given address. This function enables metrics reporting separate from pprof.

Types

type Counter

type Counter interface {
	prometheus.Counter
	ValueGetter
	AddInt(v int)
	AddUint64(v uint64)
}

func GetOrCreateCounter

func GetOrCreateCounter(name string) Counter

GetOrCreateCounter returns registered counter with the given name or creates new counter if the registry doesn't contain counter with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned counter is safe to use from concurrent goroutines.

Performance tip: prefer NewCounter instead of GetOrCreateCounter.

func NewCounter

func NewCounter(name string) Counter

NewCounter registers and returns new counter with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned counter is safe to use from concurrent goroutines.

type DurationObserver

type DurationObserver interface {
	// ObserveDuration observes duration since start time
	ObserveDuration(start time.Time)
}

type Gauge

type Gauge interface {
	prometheus.Gauge
	ValueGetter
	SetUint32(v uint32)
	SetUint64(v uint64)
	SetInt(v int)
}

func GetOrCreateGauge

func GetOrCreateGauge(name string) Gauge

GetOrCreateGauge returns registered gauge with the given name or creates new gauge if the registry doesn't contain gauge with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned gauge is safe to use from concurrent goroutines.

Performance tip: prefer NewGauge instead of GetOrCreateGauge.

func NewGauge

func NewGauge(name string) Gauge

NewGauge registers and returns gauge with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned gauge is safe to use from concurrent goroutines.

type HistTimer

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

func NewHistTimer

func NewHistTimer(name string) *HistTimer

func (*HistTimer) Child

func (h *HistTimer) Child(suffix string) *HistTimer

func (*HistTimer) PutSince

func (h *HistTimer) PutSince()

func (*HistTimer) Tag

func (h *HistTimer) Tag(pairs ...string) *HistTimer

type Histogram

type Histogram interface {
	prometheus.Histogram
	DurationObserver
}

func GetOrCreateHistogram

func GetOrCreateHistogram(name string) Histogram

GetOrCreateHistogram returns registered histogram with the given name or creates new histogram if the registry doesn't contain histogram with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned histogram is safe to use from concurrent goroutines.

Performance tip: prefer NewHistogram instead of GetOrCreateHistogram.

func NewHistogram

func NewHistogram(name string) Histogram

NewHistogram creates and returns new histogram with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned histogram is safe to use from concurrent goroutines.

type Set

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

Set is a set of metrics.

Metrics belonging to a set are exported separately from global metrics.

Set.WritePrometheus must be called for exporting metrics from the set.

func NewSet

func NewSet() *Set

NewSet creates new set of metrics.

Pass the set to RegisterSet() function in order to export its metrics via global WritePrometheus() call.

func (*Set) Collect

func (s *Set) Collect(ch chan<- prometheus.Metric)

func (*Set) Describe

func (s *Set) Describe(ch chan<- *prometheus.Desc)

func (*Set) GetOrCreateCounter

func (s *Set) GetOrCreateCounter(name string, help ...string) (prometheus.Counter, error)

GetOrCreateCounter returns registered counter in s with the given name or creates new counter if s doesn't contain counter with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned counter is safe to use from concurrent goroutines.

Performance tip: prefer NewCounter instead of GetOrCreateCounter.

func (*Set) GetOrCreateGauge

func (s *Set) GetOrCreateGauge(name string, help ...string) (prometheus.Gauge, error)

GetOrCreateGauge returns registered gauge with the given name in s or creates new gauge if s doesn't contain gauge with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned gauge is safe to use from concurrent goroutines.

Performance tip: prefer NewGauge instead of GetOrCreateGauge.

func (*Set) GetOrCreateHistogram

func (s *Set) GetOrCreateHistogram(name string, help ...string) (prometheus.Histogram, error)

GetOrCreateHistogram returns registered histogram in s with the given name or creates new histogram if s doesn't contain histogram with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned histogram is safe to use from concurrent goroutines.

Performance tip: prefer NewHistogram instead of GetOrCreateHistogram.

func (*Set) GetOrCreateSummary

func (s *Set) GetOrCreateSummary(name string, help ...string) (prometheus.Summary, error)

GetOrCreateSummary returns registered summary with the given name in s or creates new summary if s doesn't contain summary with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

Performance tip: prefer NewSummary instead of GetOrCreateSummary.

func (*Set) GetOrCreateSummaryExt

func (s *Set) GetOrCreateSummaryExt(name string, window time.Duration, quantiles map[float64]float64, help ...string) (prometheus.Summary, error)

GetOrCreateSummaryExt returns registered summary with the given name, window and quantiles in s or creates new summary if s doesn't contain summary with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

Performance tip: prefer NewSummaryExt instead of GetOrCreateSummaryExt.

func (*Set) ListMetricNames

func (s *Set) ListMetricNames() []string

ListMetricNames returns sorted list of all the metrics in s.

func (*Set) NewCounter

func (s *Set) NewCounter(name string, help ...string) (prometheus.Counter, error)

NewCounter registers and returns new counter with the given name in the s.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned counter is safe to use from concurrent goroutines.

func (*Set) NewGauge

func (s *Set) NewGauge(name string, help ...string) (prometheus.Gauge, error)

NewGauge registers and returns gauge with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

f must be safe for concurrent calls.

The returned gauge is safe to use from concurrent goroutines.

func (*Set) NewHistogram

func (s *Set) NewHistogram(name string, help ...string) (prometheus.Histogram, error)

NewHistogram creates and returns new histogram in s with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned histogram is safe to use from concurrent goroutines.

func (*Set) NewSummary

func (s *Set) NewSummary(name string, help ...string) (prometheus.Summary, error)

NewSummary creates and returns new summary with the given name in s.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

func (*Set) NewSummaryExt

func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles map[float64]float64, help ...string) (prometheus.Summary, error)

NewSummaryExt creates and returns new summary in s with the given name, window and quantiles.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

func (*Set) UnregisterAllMetrics

func (s *Set) UnregisterAllMetrics()

UnregisterAllMetrics de-registers all metrics registered in s.

func (*Set) UnregisterMetric

func (s *Set) UnregisterMetric(name string) bool

UnregisterMetric removes metric with the given name from s.

True is returned if the metric has been removed. False is returned if the given metric is missing in s.

type Summary

type Summary interface {
	prometheus.Summary
	DurationObserver
}

func GetOrCreateSummary

func GetOrCreateSummary(name string) Summary

GetOrCreateSummary returns registered summary with the given name or creates new summary if the registry doesn't contain summary with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

Performance tip: prefer NewSummary instead of GetOrCreateSummary.

func NewSummary

func NewSummary(name string) Summary

NewSummary creates and returns new summary with the given name.

name must be valid Prometheus-compatible metric with possible labels. For instance,

  • foo
  • foo{bar="baz"}
  • foo{bar="baz",aaa="b"}

The returned summary is safe to use from concurrent goroutines.

type ValueGetter

type ValueGetter interface {
	GetValue() float64
	GetValueUint64() uint64
}

Jump to

Keyboard shortcuts

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