Documentation
¶
Index ¶
- func CreateRegistryAndServeHTTP(addr string) (registry *prometheus.Registry, cancel func())
- func ServeHTTP(addr string, registry *prometheus.Registry) (cancel func())
- type HandlerPrometheusMetricsMiddleware
- type LabelComputeValueFn
- type MetricLabel
- 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 PrometheusMetricsBuilderConfig
- 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 LabelComputeValueFn ¶ added in v1.5.0
type MetricLabel ¶ added in v1.5.0
type MetricLabel struct {
Label string
ComputeValueFn LabelComputeValueFn
}
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
// contains filtered or unexported fields
}
PrometheusMetricsBuilder provides methods to decorate publishers, subscribers and handlers.
func NewPrometheusMetricsBuilder ¶
func NewPrometheusMetricsBuilder(prometheusRegistry prometheus.Registerer, namespace string, subsystem string) PrometheusMetricsBuilder
func NewPrometheusMetricsBuilderWithConfig ¶ added in v1.5.0
func NewPrometheusMetricsBuilderWithConfig(prometheusRegistry prometheus.Registerer, config PrometheusMetricsBuilderConfig) 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 PrometheusMetricsBuilderConfig ¶ added in v1.5.0
type PrometheusMetricsBuilderConfig struct {
Namespace string
Subsystem string
AdditionalLabels []MetricLabel
}
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.