Documentation ¶
Index ¶
- func CreateRegistryAndServeHTTP(addr string) (registry *prometheus.Registry, cancel func())
- func ServeHTTP(addr string, registry *prometheus.Registry) (cancel func())
- type HandlerPrometheusMetricsMiddleware
- type PrometheusMetricsBuilder
- func (b PrometheusMetricsBuilder) AddPrometheusRouterMetrics(r *message.Router)
- func (b PrometheusMetricsBuilder) DecoratePublisher(pub message.Publisher) (message.Publisher, error)
- func (b PrometheusMetricsBuilder) DecorateSubscriber(sub message.Subscriber) (message.Subscriber, error)
- func (b PrometheusMetricsBuilder) NewRouterMiddleware() HandlerPrometheusMetricsMiddleware
- type PublisherPrometheusMetricsDecorator
- type SubscriberPrometheusMetricsDecorator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateRegistryAndServeHTTP ¶
func CreateRegistryAndServeHTTP(addr string) (registry *prometheus.Registry, cancel func())
CreateRegistryAndServeHTTP establishes an HTTP server that exposes the /metrics endpoint for Prometheus at the given address. It returns a new prometheus registry (to register the metrics on) and a canceling function that ends the server.
func ServeHTTP ¶
func ServeHTTP(addr string, registry *prometheus.Registry) (cancel func())
ServeHTTP establishes an HTTP server that exposes the /metrics endpoint for Prometheus at the given address. It takes an existing Prometheus registry and returns a canceling function that ends the server.
Types ¶
type HandlerPrometheusMetricsMiddleware ¶
type HandlerPrometheusMetricsMiddleware struct {
// contains filtered or unexported fields
}
HandlerPrometheusMetricsMiddleware is a middleware that captures Prometheus metrics.
func (HandlerPrometheusMetricsMiddleware) Middleware ¶
func (m HandlerPrometheusMetricsMiddleware) Middleware(h message.HandlerFunc) message.HandlerFunc
Middleware returns the middleware ready to be used with watermill's Router.
type PrometheusMetricsBuilder ¶
type PrometheusMetricsBuilder struct { // PrometheusRegistry may be filled with a pre-existing Prometheus registry, or left empty for the default registry. PrometheusRegistry prometheus.Registerer Namespace string Subsystem string // PublishBuckets defines the histogram buckets for publish time histogram, defaulted if nil. PublishBuckets []float64 // HandlerBuckets defines the histogram buckets for handle execution time histogram, defaulted to watermill's default. HandlerBuckets []float64 }
PrometheusMetricsBuilder provides methods to decorate publishers, subscribers and handlers.
func NewPrometheusMetricsBuilder ¶
func NewPrometheusMetricsBuilder(prometheusRegistry prometheus.Registerer, namespace string, subsystem string) PrometheusMetricsBuilder
func (PrometheusMetricsBuilder) AddPrometheusRouterMetrics ¶
func (b PrometheusMetricsBuilder) AddPrometheusRouterMetrics(r *message.Router)
AddPrometheusRouterMetrics is a convenience function that acts on the message router to add the metrics middleware to all its handlers. The handlers' publishers and subscribers are also decorated. The default buckets are used for the handler execution time histogram (use your own provisioning with NewRouterMiddlewareWithConfig if needed).
func (PrometheusMetricsBuilder) DecoratePublisher ¶
func (b PrometheusMetricsBuilder) DecoratePublisher(pub message.Publisher) (message.Publisher, error)
DecoratePublisher wraps the underlying publisher with Prometheus metrics.
func (PrometheusMetricsBuilder) DecorateSubscriber ¶
func (b PrometheusMetricsBuilder) DecorateSubscriber(sub message.Subscriber) (message.Subscriber, error)
DecorateSubscriber wraps the underlying subscriber with Prometheus metrics.
func (PrometheusMetricsBuilder) NewRouterMiddleware ¶
func (b PrometheusMetricsBuilder) NewRouterMiddleware() HandlerPrometheusMetricsMiddleware
NewRouterMiddleware returns new middleware.
type PublisherPrometheusMetricsDecorator ¶
type PublisherPrometheusMetricsDecorator struct {
// contains filtered or unexported fields
}
PublisherPrometheusMetricsDecorator decorates a publisher to capture Prometheus metrics.
func (PublisherPrometheusMetricsDecorator) Close ¶
func (m PublisherPrometheusMetricsDecorator) Close() error
Close decreases the total publisher count, closes the Prometheus HTTP server and calls wrapped Close.
type SubscriberPrometheusMetricsDecorator ¶
type SubscriberPrometheusMetricsDecorator struct { message.Subscriber // contains filtered or unexported fields }
SubscriberPrometheusMetricsDecorator decorates a subscriber to capture Prometheus metrics.