go-metrics – github.com/docker/go-metrics Index | Files

package metrics

import "github.com/docker/go-metrics"

Index

Constants

const (
	InstrumentHandlerResponseSize = iota
	InstrumentHandlerRequestSize
	InstrumentHandlerDuration
	InstrumentHandlerCounter
	InstrumentHandlerInFlight
)

Functions

func Deregister

func Deregister(n *Namespace)

Deregister removes all the metrics in the provided namespace from the global metrics registry

func Handler

func Handler() http.Handler

Handler returns the global http.Handler that provides the prometheus metrics format on GET requests. This handler is no longer instrumented.

func InstrumentHandler

func InstrumentHandler(metrics []*HTTPMetric, handler http.Handler) http.HandlerFunc

func InstrumentHandlerFunc

func InstrumentHandlerFunc(metrics []*HTTPMetric, handlerFunc http.HandlerFunc) http.HandlerFunc

func Register

func Register(n *Namespace)

Register adds all the metrics in the provided namespace to the global metrics registry

func StartTimer

func StartTimer(timer Timer) (done func())

StartTimer begins a timer observation at the callsite. When the target operation is completed, the caller should call the return done func().

Types

type Counter

type Counter interface {
	// Inc adds Sum(vs) to the counter. Sum(vs) must be positive.
	//
	// If len(vs) == 0, increments the counter by 1.
	Inc(vs ...float64)
}

Counter is a metrics that can only increment its current count

type Gauge

type Gauge interface {
	Inc(...float64)
	Dec(...float64)

	// Add adds the provided value to the gauge's current value
	Add(float64)

	// Set replaces the gauge's current value with the provided value
	Set(float64)
}

Gauge is a metric that allows incrementing and decrementing a value

type HTTPHandlerOpts

type HTTPHandlerOpts struct {
	DurationBuckets     []float64
	RequestSizeBuckets  []float64
	ResponseSizeBuckets []float64
}

HTTPHandlerOpts describes a set of configurable options of http metrics

type HTTPMetric

type HTTPMetric struct {
	prometheus.Collector
	// contains filtered or unexported fields
}

type LabeledCounter

type LabeledCounter interface {
	WithValues(vs ...string) Counter
}

LabeledCounter is counter that must have labels populated before use.

type LabeledGauge

type LabeledGauge interface {
	WithValues(labels ...string) Gauge
}

LabeledGauge describes a gauge the must have values populated before use.

type LabeledTimer

type LabeledTimer interface {
	WithValues(labels ...string) *labeledTimerObserver
}

LabeledTimer is a timer that must have label values populated before use.

type Labels

type Labels map[string]string

type Namespace

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

Namespace describes a set of metrics that share a namespace and subsystem.

func NewNamespace

func NewNamespace(name, subsystem string, labels Labels) *Namespace

NewNamespace returns a namespaces that is responsible for managing a collection of metrics for a particual namespace and subsystem

labels allows const labels to be added to all metrics created in this namespace and are commonly used for data like application version and git commit

func (*Namespace) Add

func (n *Namespace) Add(collector prometheus.Collector)

func (*Namespace) Collect

func (n *Namespace) Collect(ch chan<- prometheus.Metric)

func (*Namespace) Describe

func (n *Namespace) Describe(ch chan<- *prometheus.Desc)

func (*Namespace) NewCounter

func (n *Namespace) NewCounter(name, help string) Counter

func (*Namespace) NewDefaultHttpMetrics

func (n *Namespace) NewDefaultHttpMetrics(handlerName string) []*HTTPMetric

func (*Namespace) NewDesc

func (n *Namespace) NewDesc(name, help string, unit Unit, labels ...string) *prometheus.Desc

func (*Namespace) NewGauge

func (n *Namespace) NewGauge(name, help string, unit Unit) Gauge

func (*Namespace) NewHttpMetrics

func (n *Namespace) NewHttpMetrics(handlerName string, durationBuckets, requestSizeBuckets, responseSizeBuckets []float64) []*HTTPMetric

func (*Namespace) NewHttpMetricsWithOpts

func (n *Namespace) NewHttpMetricsWithOpts(handlerName string, opts HTTPHandlerOpts) []*HTTPMetric

func (*Namespace) NewInFlightGaugeMetric

func (n *Namespace) NewInFlightGaugeMetric(handlerName string) *HTTPMetric

func (*Namespace) NewLabeledCounter

func (n *Namespace) NewLabeledCounter(name, help string, labels ...string) LabeledCounter

func (*Namespace) NewLabeledGauge

func (n *Namespace) NewLabeledGauge(name, help string, unit Unit, labels ...string) LabeledGauge

func (*Namespace) NewLabeledTimer

func (n *Namespace) NewLabeledTimer(name, help string, labels ...string) LabeledTimer

func (*Namespace) NewRequestDurationMetric

func (n *Namespace) NewRequestDurationMetric(handlerName string, buckets []float64) *HTTPMetric

func (*Namespace) NewRequestSizeMetric

func (n *Namespace) NewRequestSizeMetric(handlerName string, buckets []float64) *HTTPMetric

func (*Namespace) NewRequestTotalMetric

func (n *Namespace) NewRequestTotalMetric(handlerName string) *HTTPMetric

func (*Namespace) NewResponseSizeMetric

func (n *Namespace) NewResponseSizeMetric(handlerName string, buckets []float64) *HTTPMetric

func (*Namespace) NewTimer

func (n *Namespace) NewTimer(name, help string) Timer

func (*Namespace) WithConstLabels

func (n *Namespace) WithConstLabels(labels Labels) *Namespace

WithConstLabels returns a namespace with the provided set of labels merged with the existing constant labels on the namespace.

Only metrics created with the returned namespace will get the new constant
labels.  The returned namespace must be registered separately.

type Timer

type Timer interface {
	// Update records an observation, duration, and converts to the target
	// units.
	Update(duration time.Duration)

	// UpdateSince will add the duration from the provided starting time to the
	// timer's summary with the precisions that was used in creation of the timer
	UpdateSince(time.Time)
}

Timer is a metric that allows collecting the duration of an action in seconds

type Unit

type Unit string

Unit represents the type or precision of a metric that is appended to the metrics fully qualified name

const (
	Nanoseconds Unit = "nanoseconds"
	Seconds     Unit = "seconds"
	Bytes       Unit = "bytes"
	Total       Unit = "total"
)

Source Files

counter.go docs.go gauge.go handler.go helpers.go namespace.go register.go timer.go unit.go

Version
v0.0.1 (latest)
Published
Aug 28, 2019
Platform
js/wasm
Imports
6 packages
Last checked
now

Tools for package owners.