metrics

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller holds details about a metrics monitor instance.

func CreateController

func CreateController(opts Options) (*Controller, error)

CreateController initializes and creates a new controller

func (*Controller) NewCounterVecWithCallback

func (mws *Controller) NewCounterVecWithCallback(
	name string, help string, variableLabels []string, subItems VectorMetric,
) error

NewCounterVecWithCallback creates a vector of counters metric where their data are populated by calling a callback

func (*Controller) NewCounterWithCallback

func (mws *Controller) NewCounterWithCallback(name string, help string, handler ValueHandler) error

NewCounterWithCallback creates a single counter metric where its data is populated by calling a callback

func (*Controller) NewGaugeVecWithCallback

func (mws *Controller) NewGaugeVecWithCallback(
	name string, help string, variableLabels []string, subItems VectorMetric,
) error

NewGaugeVecWithCallback creates a vector of gauges metric where their data are populated by calling a callback

func (*Controller) NewGaugeWithCallback

func (mws *Controller) NewGaugeWithCallback(name string, help string, handler ValueHandler) error

NewGaugeWithCallback creates a single gauge metric where its data is populated by calling a callback

func (*Controller) Registry

func (mws *Controller) Registry() *prometheus.Registry

Registry returns the prometheus registry object

func (*Controller) Start

func (mws *Controller) Start() error

Start starts the monitor's internal web server

func (*Controller) Stop

func (mws *Controller) Stop()

Stop destroys the monitor and stops the internal web server

type HealthCallback

type HealthCallback func() string

HealthCallback indicates a function that returns a string that will be returned as the output.

type Options

type Options struct {
	// If Server is provided, use this server instead of creating a new one.
	Server *webserver.Server

	// Server name to use when sending response headers. Defaults to 'metrics-server'.
	Name string

	// Address is the bind address to attach the internal web server.
	Address string

	// Port is the port number the internal web server will use.
	Port uint16

	// TLSConfig optionally provides a TLS configuration for use.
	TLSConfig *tls.Config

	// A callback to call if an error is encountered.
	ListenErrorHandler webserver.ListenErrorHandler

	// AccessToken is an optional access token required to access the status endpoints.
	AccessToken string

	// If RequestAccessTokenInHealth is enabled, access token checked also in '/health' endpoint.
	RequestAccessTokenInHealth bool

	// HealthCallback is a function that returns an object which, in turn, will be converted to JSON format.
	HealthCallback HealthCallback

	// Expose debugging profiles /debug/pprof endpoint.
	EnableDebugProfiles bool

	// Middlewares additional set of middlewares for the endpoints.
	Middlewares []webserver.HandlerFunc

	// If HealthApiPath is defined, it will override the default "/health" path for health requests.
	HealthApiPath string
	// If MetricsApiPath is defined, it will override the default "/metrics" path for metrics requests.
	MetricsApiPath string
	// If DebugProfilesApiPath is defined, it will override the default "/debug/pprof" path for debug profile requests.
	DebugProfilesApiPath string
}

Options specifies metrics controller initialization options.

type ValueHandler

type ValueHandler func() float64

type VectorMetric

type VectorMetric []struct {
	Values  []string
	Handler ValueHandler
}

Jump to

Keyboard shortcuts

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