rlightning.utils.logger.handlers

class rlightning.utils.logger.handlers.MetricsHandler(backend: MetricsBackend)[source]

Bases: Handler

A logging handler that routes metrics to configured backends.

close()[source]

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

emit(record: LogRecord)[source]

Place metric payloads onto the queue for background processing.

This method is called by the logging system for each log record. It checks for a metric_payload attribute on the record and, if present, adds it to the processing queue.

Parameters:

record – The log record to process.

rlightning.utils.logger.handlers.build_metrics_backend(cfg: LogConfig) MetricsBackend[source]

Build a list of metrics backends based on the provided configuration.

Parameters:

cfg – The application’s configuration object.

Returns:

A list of initialized MetricsBackend instances.