common_dagster.monitoring.repo
The single reusable repository for durable container monitoring.
Writes are fail-safe after their arguments have been validated: an
observability outage is logged and returned as False but never takes down
successful business work. Report reads are fail-loud because unavailable
monitoring must never be presented as an empty, healthy result.
Provisioning owns DDL. This runtime repository only reads and writes the four
common tables in the named monitoring database target.
Classes
MonitoringRepo
The four-table monitoring API, parameterized only by the container it serves.
__init__
def __init__(db: DBClient, container: str, *, run_id: str | None = None, run_date: dt.date | None = None) -> NoneFields and properties declared here; inherited members belong to the bases above.
container
container = containerdb
db = dbrun_date
run_date = run_daterun_id
run_id = _present(run_id or f'local-{uuid4().hex}', 'run_id')schema
schema = containerbind_run_date
async def bind_run_date(run_date: dt.date) -> boolAuthoritatively bind a discovered business date on an open run.
Daily workloads can only know the actual completed session after a fetch step. This explicit correction may replace a provisional date while the run is open; terminal evidence remains immutable.
finish_run
async def finish_run(status: RunTerminalStatus, *, error: str | None = None, finished_at: dt.datetime | None = None) -> boolClose a run once; callers first idempotently call start_run.
The update-only terminal leg prevents a terminal-first callback from inventing incomplete run identity. Dagster terminal consumers therefore open the exact run idempotently before calling this method.
finish_stage
async def finish_stage(stage_id: str, status: StageTerminalStatus, *, message: str | None = None, finished_at: dt.datetime | None = None) -> boolClose one exact attempt without erasing prior failed attempts.
ident
@staticmethoddef ident(schema: str, name: str) -> _sql.IdentifierA safely composed schema-qualified identifier; never string formatting.
read_findings
async def read_findings(run_id: str | None = None) -> list[dict[str, Any]]read_period_report
async def read_period_report(start_date: dt.date, end_date: dt.date) -> list[dict[str, Any]]read_run
async def read_run(run_id: str | None = None) -> dict[str, Any] | Noneread_run_report
async def read_run_report(run_id: str | None = None) -> dict[str, Any]read_stages
async def read_stages(run_id: str | None = None) -> list[dict[str, Any]]read_target_receipts
async def read_target_receipts(run_id: str | None = None) -> list[dict[str, Any]]record_check_result
async def record_check_result(receipt_id: str, *, checks_total: int, checks_failed: int, message: str | None = None) -> boolAttach observed check counts without changing target completion.
record_finding_summaries
async def record_finding_summaries(stage_id: str, findings: Sequence[FindingInput | Mapping[str, object]], *, receipt_id: str | None = None, recorded_at: dt.datetime | None = None) -> tuple[str, ...]Persist grouped anomaly types; never one row per symbol/date/gap.
record_target_receipt
async def record_target_receipt(stage_id: str, target_type: str, target_name: str, *, target_key: str | None = None, status: TargetStatus = 'complete', rows_written: int | None = None, rows_rejected: int | None = None, rows_total_after: int | None = None, checks_total: int | None = None, checks_failed: int | None = None, message: str | None = None, recorded_at: dt.datetime | None = None) -> strUpsert one idempotent receipt for the exact target slice.
start_run
async def start_run(flow_name: str, job_name: str, job_type: JobType, *, run_date: dt.date | None = None, started_at: dt.datetime | None = None) -> strIdempotently open this repo’s run and always return its identity.
start_stage
async def start_stage(stage_name: str, *, attempt: int = 1, started_at: dt.datetime | None = None) -> strIdempotently open one named attempt and return its stable identity.
MonitoringUnavailableError
Bases: RuntimeError
A report read failed; consumers must not invent an empty healthy state.
__init__
def __init__(surface: str, error: object) -> NoneFields and properties declared here; inherited members belong to the bases above.
error
error = errorsurface
surface = surfaceTypes and values
log
log = structlog.get_logger('common_dagster.monitoring')