metrics

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LatencyBuckets is the collection of buckets to use for latency/request duration histograms.
	// If you wish to change this, this should be changed _before_ creating any objects which provide latency histograms,
	// as this variable is used at collector creation time.
	LatencyBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Namespace for the collectors
	Namespace string
	// NativeHistogramBucketFactor is used for native histograms, see
	// https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts
	NativeHistogramBucketFactor float64
	// NativeHistogramMaxBucketNumber is used to define the max number of buckets
	// in a native histogram, see https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts
	NativeHistogramMaxBucketNumber uint32
}

Config is the general set of configuration options for creating prometheus Collectors

func DefaultConfig

func DefaultConfig(namespace string) Config

DefaultConfig returns a Config with the provided namespace and all other values set to defaults.

type Exporter

type Exporter struct {
	Registerer prometheus.Registerer
	Gatherer   prometheus.Gatherer
	Port       int
}

Exporter exports prometheus metrics

func NewExporter

func NewExporter(cfg ExporterConfig) *Exporter

NewExporter returns a new Exporter using the provided config. Empty values in the config apply default prometheus values.

func (*Exporter) RegisterCollectors

func (e *Exporter) RegisterCollectors(metrics ...prometheus.Collector) error

RegisterCollectors registers the provided collectors with the Exporter's Registerer. If there is an error registering any of the provided collectors, registration is halted and an error is returned.

func (*Exporter) Run

func (e *Exporter) Run(stopCh <-chan struct{}) error

Run creates an HTTP server which exposes a /metrics endpoint on the configured port (if <=0, uses the default 9090)

type ExporterConfig

type ExporterConfig struct {
	Registerer prometheus.Registerer
	Gatherer   prometheus.Gatherer
	Port       int
}

ExporterConfig is the configuration used for the Exporter

type Provider

type Provider interface {
	PrometheusCollectors() []prometheus.Collector
}

Provider is an interface which describes any object which can provide the prometheus Collectors is uses for registration

Jump to

Keyboard shortcuts

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