Skip to content

Metrics

lacme.metrics

Optional Prometheus metrics for lacme.

Subscribes to :class:~lacme.events.EventDispatcher events and updates Prometheus counters and gauges. Requires prometheus_client (install with pip install lacme[prometheus]).

MetricsCollector

Prometheus metrics collector for lacme events.

Created by :func:setup_metrics. Subscribes to the event dispatcher and updates counters/gauges on each event.

setup_metrics

setup_metrics(dispatcher: EventDispatcher, registry: Any = None) -> MetricsCollector

Register Prometheus metrics and subscribe to lacme events.

Parameters:

Name Type Description Default
dispatcher EventDispatcher

Event dispatcher to subscribe to.

required
registry Any

Optional Prometheus CollectorRegistry. Defaults to the global REGISTRY. Pass a custom registry to avoid conflicts when creating multiple collectors.

None

Returns:

Name Type Description
A MetricsCollector

class:MetricsCollector holding all metric objects.

Raises:

Type Description
ImportError

If prometheus_client is not installed.