prometheus

package
v4.0.0-...-4d3fb5c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHandler = &Handler{
	TrimPrefix: stats.DefaultEngine.Prefix,
}

DefaultHandler is a prometheus handler configured to trim the default metric namespace off of metrics that it handles.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Setting this field will trim this prefix from metric namespaces of the
	// metrics received by this handler.
	//
	// Unlike statsd-like systems, it is common for prometheus metrics to not
	// be prefixed and instead use labels to identify which service or group
	// of services the metrics are coming from. The intent of this field is to
	// provide support for this use case.
	//
	// Note that triming only applies to the metric namespace, the metric
	// name will always be left untouched.
	//
	// If empty, no prefix trimming is done.
	TrimPrefix string

	// MetricTimeout defines how long the handler exposes metrics that aren't
	// receiving updates.
	//
	// The default is to use a 2 minutes metric timeout.
	MetricTimeout time.Duration

	// Buckets is the registry of histogram buckets used by the handler,
	// If nil, stats.Buckets is used instead.
	Buckets stats.HistogramBuckets
	// contains filtered or unexported fields
}

Handler is a type that bridges the stats API to a prometheus-compatible HTTP endpoint.

Typically, a program creates one Handler, registers it to the stats package, and adds it to the muxer used by the application under the /metrics path.

The handle ignores histograms that have no buckets set.

func (*Handler) HandleMeasures

func (h *Handler) HandleMeasures(mtime time.Time, measures ...stats.Measure)

HandleMeasures satisfies the stats.Handler interface.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP satisfies the http.Handler interface.

func (*Handler) WriteStats

func (h *Handler) WriteStats(w io.Writer)

WriteStats accepts a writer and pushes metrics (one at a time) to it. An example could be if you just want to print all the metrics on to Stdout It will not call flush. Make sure the Close and Flush are handled at the caller

Jump to

Keyboard shortcuts

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