metric

package
v0.0.0-...-3c16d7b Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHandler

func HTTPHandler() http.Handler

HTTPHandler returns http.Handler used to export metrics.

func MustRegister

func MustRegister(m Metric)

MustRegister registers the provided Metric and panics if any error occurs.

func Register

func Register(m Metric) error

Register registers the provided Metric.

Types

type Counter

type Counter interface {
	Metric
	Add(value float64, labelValues ...string)
}

Counter is a Metric that represents a single numerical value that only ever goes up.

func NewCounter

func NewCounter(name, desc string, labelNames []string) Counter

NewCounter creates a Counter metric partitioned by the given label names.

type EmptyExporter

type EmptyExporter struct {
}

func (*EmptyExporter) HTTPHandler

func (e *EmptyExporter) HTTPHandler() http.Handler

func (*EmptyExporter) NewCounter

func (e *EmptyExporter) NewCounter(name, desc string, labelNames []string) Counter

func (*EmptyExporter) NewGauge

func (e *EmptyExporter) NewGauge(name, desc string, labelNames []string) Gauge

func (*EmptyExporter) NewHistogram

func (e *EmptyExporter) NewHistogram(name, desc string, buckets []float64, labelNames []string) Histogram

type Exporter

type Exporter interface {
	// NewCounter creates a Counter metric partitioned by the given label names.
	NewCounter(name, desc string, labelNames []string) Counter
	// NewGauge creates a Gauge metric partitioned by the given label names.
	NewGauge(name, desc string, labelNames []string) Gauge
	// NewHistogram creates a histogram metric partitioned by the given label names.
	NewHistogram(name, desc string, buckets []float64, labelNames []string) Histogram
	// HTTPHandler returns http.Handler used to export metrics.
	HTTPHandler() http.Handler
}

Exporter creates all kinds Metric, and return the http.Handler used to export metrics.

type Gauge

type Gauge interface {
	Metric
	Set(value float64, labelValues ...string)
}

Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down.

func NewGauge

func NewGauge(name, desc string, labelNames []string) Gauge

NewGauge creates a Gauge metric partitioned by the given label names.

type Histogram

type Histogram interface {
	Metric
	Observe(value float64, labelValues ...string)
}

Histogram counts individual observations from an event or sample stream in configurable buckets.

func NewHistogram

func NewHistogram(name, desc string, buckets []float64, labelNames []string) Histogram

NewHistogram creates a histogram metric partitioned by the given label names.

type Metric

type Metric interface {
	// Register registers the Metric.
	Register() error
	// Unregister unregisters the Metric.
	Unregister() bool
	// Reset deletes all values of the Metric.
	Reset()
}

Metric models basic operations of metric being exported. Implementations of Metric in this package are Counter, Gauge and Histogram.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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