Skip to content

symfonic.core.observability.postgres_metrics_store

postgres_metrics_store

PostgresMetricsStore — durable :class:MetricsStore on llm_calls (v8.8.0).

Backed by the scaffold-owned Alembic migration 005_llm_calls. Mirrors postgres_budget_store.py: a framework-agnostic async session factory, lazy sqlalchemy.text import (core never hard-requires SQLAlchemy at module load), and best-effort semantics (the :class:BufferedMetricsSink that wraps this store swallows + logs write failures).

All reads are tenant-scoped by the caller and return the snapshot dict shape ConversationMetricsCollector.snapshots() emits, so the scaffold's build_conversation_detail() and response models work unchanged.

PostgresMetricsStore

PostgresMetricsStore(session_factory: SessionFactory)

Durable :class:MetricsStore backed by the llm_calls table.

Source code in src/symfonic/core/observability/postgres_metrics_store.py
def __init__(self, session_factory: SessionFactory) -> None:
    self._session_factory = session_factory