Skip to content

Prometheus Extension

from sqlspec.extensions.prometheus import PrometheusStatementObserver, enable_metrics

Prometheus statement observer and configuration helper exporting statement counters and duration histograms via ObservabilityConfig. See the Observability Guide for usage examples.

Statement Observer & Configuration Helper

PrometheusStatementObserver

Statement observer that records Prometheus metrics.

enable_metrics

enable_metrics(
    *,
    base_config=None,
    namespace="sqlspec",
    subsystem="driver",
    registry=None,
    label_names=("db_system", "operation"),
    duration_buckets=None,
)

Attach a Prometheus-backed statement observer to the provided config.