prometheus

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 5 Imported by: 0

README

fastbreaker

Go Reference CI

fastbreaker.prometheus simplifies regitering metrics generated from fastbreaker into prometheus.

Installation

go get github.com/bluekiri/fastbreaker/prometheus

Usage

The function prometheus.RegisterMetricsToDefaultRegisterer registers the fastbreaker.FastBreaker metrics with the default Registerer.

The function prometheus.RegisterMetrics registers the fastbreaker.FastBreaker metrics with the provided Registerer.

The function RegisterMetricsWithFactory registers the fastbreaker.FastBreaker metrics with the provided promauto.Factory.

All three functions return an error if the circuit breaker name is not a valid UTF-8 string.

Example

var cb fastbreaker.FastBreaker

prometheus.RegisterMetricsToDefaultRegisterer("my-circuit-breaker", cb)

License

The MIT License (MIT)

See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	// MetricsNamespace is the common metric namespace (prefix).
	MetricsNamespace = "circuit_breaker"

	// ExecutionsMetricName is the suffix of the executions metric.
	ExecutionsMetricName = "executions_total"

	// OpenStateMetricName is the suffix of the open metric.
	OpenStateMetricName = "open"

	// SlidingFailureRateMetricName is the suffix of the sliding failure rate metric.
	SlidingFailureRateMetricName = "sliding_failure_rate"

	// CircuitBreakerNameLabel is the label name for the circuit breaker name.
	CircuitBreakerNameLabel = "name"
	// ExecutionStatusLabel is the label name for the execution status.
	ExecutionStatusLabel = "status"
)

Variables

View Source
var ErrInvalidCircuitBreakerName = errors.New("invalid circuit breaker name")

Functions

func RegisterMetrics

func RegisterMetrics(circuitBreakerName string, cb fastbreaker.FastBreaker, registerer prom.Registerer) (fastbreaker.FastBreaker, error)

RegisterMetrics registers the FastBreaker metrics using the provided Registerer. RegisterMetrics will label the FastBreaker metrics with the circuitBreakerName. RegisterMetrics will return an ErrInvalidCircuitBreakerName error if the circuitBreakerName string is not a valid utf-8 string.

func RegisterMetricsToDefaultRegisterer

func RegisterMetricsToDefaultRegisterer(circuitBreakerName string, cb fastbreaker.FastBreaker) (fastbreaker.FastBreaker, error)

RegisterMetricsToDefaultRegisterer registers the FastBreaker metrics using the prometheus DefaultRegisterer. RegisterMetricsToDefaultRegisterer will label the FastBreaker metrics with the circuitBreakerName. RegisterMetricsToDefaultRegisterer will return an ErrInvalidCircuitBreakerName error if the circuitBreakerName string is not a valid utf-8 string.

func RegisterMetricsWithFactory

func RegisterMetricsWithFactory(circuitBreakerName string, cb fastbreaker.FastBreaker, factory promauto.Factory) (fastbreaker.FastBreaker, error)

RegisterMetricsWithFactory registers the FastBreaker metrics using the provided Factory. RegisterMetricsWithFactory will label the FastBreaker metrics with the circuitBreakerName. RegisterMetricsWithFactory will return an ErrInvalidCircuitBreakerName error if the circuitBreakerName string is not a valid utf-8 string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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