Skip to content

prometheus

etrack.providers.adapters.sink.prometheus

providers/adapters/sink/prometheus: PrometheusAdapter — every run counted, timed and priced as Prometheus metrics.

Each closed span counts once, by kind, name and outcome, and its latency lands in a histogram; model calls add their tokens by type and their cost, by model and by the node that made them (a NODE's or a RUN's total is never counted again); runs in flight are a gauge. Each typed fact (etrack.models.fact) counts in a counter of its own, fact_<name>, split by the fields its class marks as labels. The registry is the adapter's own, so two adapters never collide. Prometheus scrapes app — mount it in the host (/metrics) or serve it with GranianAdapter — and Grafana reads Prometheus. Names stay bounded: a span's name is its node, tool or model, never a free text.

PrometheusAdapter

PrometheusAdapter(**given: Unpack[PrometheusConfig])

Run metrics in an own registry, scraped from app.

Keyword arguments as PrometheusConfig names them; what is not given, ETRACK_PROMETHEUS_* fills.

app property

app: Asgi

The ASGI app Prometheus scrapes — mount it at /metrics.

registry property

registry: CollectorRegistry

The adapter's own registry: what app exposes, what a test or a push reads.

health async

health() -> bool

Open: its metrics are being kept.

send async

send(view: EventView) -> None

A run's start counts it in flight; every close counts, times and prices the span; a fact counts itself.

PrometheusView

Bases: EventView

What a metric needs of a frame: what it is, how it ended, how long it took, what it spent.