Prometheus#
Prometheus metrics extension for SQLSpec. Provides a statement observer and configuration helpers that record SQL execution counts, duration histograms, and row count histograms.
Configuration#
Use sqlspec.config.PrometheusConfig in extension_config["prometheus"].
These settings apply across adapters; no adapter-specific subtype is needed.
- class sqlspec.config.PrometheusConfig[source]
Bases:
TypedDictConfiguration options for Prometheus metrics.
Use in
extension_config["prometheus"].- enabled: NotRequired[bool]
True.
- Type:
Enable the extension. Default
- namespace: NotRequired[str]
"sqlspec".- Type:
Prometheus metric namespace. Default
- subsystem: NotRequired[str]
"driver".- Type:
Prometheus metric subsystem. Default
- registry: NotRequired[Any]
Custom Prometheus registry (defaults to the global registry).
- label_names: NotRequired[tuple[str, ...]]
("driver", "operation").
- Type:
Labels applied to metrics. Default
- duration_buckets: NotRequired[tuple[float, ...]]
Histogram buckets for query duration (seconds).