push

package
v1.25.11 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMetrics

func InitMetrics(initFunctions []func() (prometheus.Collector, error)) (err error)

InitMetrics fills the collector variables with some Prometheus metrics and automatically registers them.

func NewCounterVecWithError added in v1.21.8

func NewCounterVecWithError(opts prometheus.CounterOpts, labelNames []string) (counter *prometheus.CounterVec, err error)

NewCounterVecWithError run promauto.NewCounterVec() catching the panic and returning an error

func NewCounterWithError

func NewCounterWithError(opts prometheus.CounterOpts) (counter prometheus.Counter, err error)

NewCounterWithError run promauto.NewCounter() catching the panic and returning an error

func NewGaugeWithError

func NewGaugeWithError(opts prometheus.GaugeOpts) (gauge prometheus.Gauge, err error)

NewGaugeWithError run promauto.NewGauge() catching the panic and returning an error

func NewHistogramWithError

func NewHistogramWithError(opts prometheus.HistogramOpts) (histogram prometheus.Histogram, err error)

NewHistogramWithError run promauto.NewHistogram() catching the panic and returning an error

func SendMetrics

func SendMetrics(job, gatewayURL, gatewayAuthToken string) error

SendMetrics pushes the metrics to the configured prometheus push gateway

func SendMetricsInLoop

func SendMetricsInLoop(ctx context.Context, job, gatewayURL, gatewayAuthToken string, timeBetweenPush time.Duration)

SendMetricsInLoop pushes the metrics in a loop until context is done

func UnregisterMetrics

func UnregisterMetrics() error

UnregisterMetrics unregister all prometheus collectors safe in the collectors variable

Types

type GatewayClient

type GatewayClient struct {
	AuthToken string

	HTTPClient http.Client
}

GatewayClient is a simple wrapper over http.Client so that prometheus can do HTTP requests with the given authentication header

func (*GatewayClient) Do

func (pgc *GatewayClient) Do(request *http.Request) (*http.Response, error)

Do is a simple wrapper over http.Client.Do method that includes the authentication header configured in the PushGatewayClient instance

Jump to

Keyboard shortcuts

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