metrics

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

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

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
}

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.

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

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

Close decreases the total publisher count, closes the Prometheus HTTP server and calls wrapped Close.

func (PublisherPrometheusMetricsDecorator) Publish

func (m PublisherPrometheusMetricsDecorator) Publish(ctx context.Context,
	topic string, messages ...*message.Message) (err error)

Publish updates the relevant publisher metrics and calls the wrapped publisher's Publish.

type SubscriberPrometheusMetricsDecorator

type SubscriberPrometheusMetricsDecorator struct {
	message.Subscriber
	// contains filtered or unexported fields
}

SubscriberPrometheusMetricsDecorator decorates a subscriber to capture Prometheus metrics.

Jump to

Keyboard shortcuts

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