Migration 18: ops.contract_check_log table — append-only log of probes
against the Tracksolid Pro endpoints we depend on.
New worker app/workers/contract_check.py — per run:
- jimi.oauth.token.get (token refresh succeeds)
- jimi.user.device.location.list per configured target (parse first item
with JimiPollFix)
- jimi.device.location.get with a sample IMEI from the list (parse first
item with JimiPollFix)
Each probe logs success or {error_class, error_detail, sample}; failures
are recorded, not raised.
slo_metrics now also computes contract_drift_days = days since the most-
recent successful probe of the laggard endpoint. With threshold 1d (from
mig 5), a single failed daily run flips the badge red within 24h.
cron entrypoint registers the check daily at 02:00 UTC plus once on
startup, gated on TRACKSOLID_APP_KEY + a configured target.
31 lines
1,017 B
SQL
31 lines
1,017 B
SQL
-- migrate:up
|
|
--
|
|
-- Append-only log of contract-check probes against the Tracksolid Pro API.
|
|
-- One row per (endpoint, attempt). The SLO worker reads this to compute
|
|
-- contract_drift_days = days since the most-recent successful probe for the
|
|
-- laggard endpoint. Threshold 1 day → red badge if any endpoint hasn't
|
|
-- validated cleanly in the last 24h.
|
|
|
|
CREATE SCHEMA IF NOT EXISTS ops;
|
|
|
|
CREATE TABLE ops.contract_check_log (
|
|
check_id bigserial PRIMARY KEY,
|
|
endpoint text NOT NULL,
|
|
target text,
|
|
success bool NOT NULL,
|
|
error_class text,
|
|
error_detail text,
|
|
sample jsonb,
|
|
parser_version text,
|
|
checked_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX contract_check_endpoint_time_idx
|
|
ON ops.contract_check_log (endpoint, checked_at DESC);
|
|
|
|
CREATE INDEX contract_check_success_time_idx
|
|
ON ops.contract_check_log (success, checked_at DESC);
|
|
|
|
-- migrate:down
|
|
|
|
DROP TABLE IF EXISTS ops.contract_check_log;
|