symfonic.core.observability.metrics_store¶
metrics_store ¶
Storage-agnostic durable metrics contracts, buffering, and factory.
BufferedMetricsSink ¶
BufferedMetricsSink(store: MetricsStore, *, batch_size: int = 25, flush_interval_s: float = 2.0, max_queue: int = 10000)
Source code in src/symfonic/core/observability/metrics_store.py
loss_counts
property
¶
Losses by durable record family, safe for health reporting.
lost_fallback_events
property
¶
Fallback rows evicted, failed, or unconfirmed after cancellation.
block_tenant
async
¶
Reject future rows, await active writes, and discard queued rows.
Source code in src/symfonic/core/observability/metrics_store.py
ensure_indexes ¶
Delegate to the wrapped store's index bootstrap, if it has one.
flush
async
¶
Drain the whole queue now (deterministic for tests / shutdown).
Source code in src/symfonic/core/observability/metrics_store.py
record ¶
Synchronous, non-blocking enqueue. Drops oldest on overflow.
Source code in src/symfonic/core/observability/metrics_store.py
record_event ¶
Enqueue one metadata-only execution event.
Source code in src/symfonic/core/observability/metrics_store.py
MetricsReader ¶
Bases: Protocol
Rich, tenant-scoped read side backing the admin dashboards.
conversation_detail
async
¶
Return rows shaped like ConversationMetricsCollector.snapshots().
MetricsSink ¶
Bases: Protocol
Durable write side of a metrics backend.
MetricsStore ¶
Bases: MetricsSink, MetricsReader, Protocol
A full metrics backend: durable writes + rich tenant-scoped reads.
get_metrics_store ¶
Return the registered metrics store, or None (in-memory only).
make_metrics_store ¶
make_metrics_store(identifier: str | None, *, postgres_session_factory: Any = None, mongo_database_factory: Any = None, mongo_retention_days: int = 90) -> MetricsStore | None
Resolve a METRICS_STORE identifier to a concrete backend.
none / "" → None (in-memory collector only, today's default).
postgres → :class:PostgresMetricsStore (needs postgres_session_factory
+ symfonic-core[postgres]). mongo → :class:MongoMetricsStore
(needs mongo_database_factory + symfonic-core[mongodb]). A dotted
path (my_pkg.mod:MyStore or my_pkg.mod.MyStore) → the adopter's
zero-arg-constructible MetricsStore.
Raises ValueError with a pip install hint on a missing extra and
on an unknown identifier, so misconfiguration fails loudly at startup.
Source code in src/symfonic/core/observability/metrics_store_factory.py
set_metrics_store ¶
Register the process-wide metrics store (or None to disable).