feat(admin): observability — job history, live now-analyzing, durations & metrics (0.84.0) (#6)
Some checks failed
deploy / test-backend (push) Failing after 19m59s
deploy / test-frontend (push) Successful in 9m54s
deploy / build-and-push (push) Has been skipped
deploy / deploy (push) Has been skipped

This commit was merged in pull request #6.
This commit is contained in:
2026-06-16 12:21:13 +00:00
parent 790549636f
commit d51ab2a049
41 changed files with 3655 additions and 21 deletions

View File

@@ -86,6 +86,7 @@ pub struct DaemonConfig {
pub daily_at: NaiveTime,
pub tz: Tz,
pub retention_days: u32,
pub metrics_retention_days: u32,
pub session_expired: Arc<AtomicBool>,
/// Live status surface updated by the cron + workers.
pub status: StatusHandle,
@@ -139,6 +140,7 @@ pub fn spawn(pool: PgPool, cancel: CancellationToken, cfg: DaemonConfig) -> Daem
daily_at,
tz,
retention_days,
metrics_retention_days,
session_expired,
status,
job_timeout,
@@ -152,6 +154,7 @@ pub fn spawn(pool: PgPool, cancel: CancellationToken, cfg: DaemonConfig) -> Daem
daily_at,
tz,
retention_days,
metrics_retention_days,
metadata,
status: status.clone(),
};
@@ -190,6 +193,7 @@ struct CronContext {
daily_at: NaiveTime,
tz: Tz,
retention_days: u32,
metrics_retention_days: u32,
metadata: Arc<dyn MetadataPass>,
status: StatusHandle,
}
@@ -271,6 +275,7 @@ impl CronContext {
let metadata = &self.metadata;
let pool = &self.pool;
let retention_days = self.retention_days;
let metrics_retention_days = self.metrics_retention_days;
let status = &self.status;
let body = async move {
match metadata.run().await {
@@ -290,6 +295,10 @@ impl CronContext {
Ok(n) => tracing::info!(reaped = n, "cron: done-job reaper finished"),
Err(e) => tracing::error!(?e, "cron: done-job reaper failed"),
}
match crate::repo::crawl_metrics::reap(pool, metrics_retention_days).await {
Ok(n) => tracing::info!(reaped = n, "cron: crawl-metrics reaper finished"),
Err(e) => tracing::error!(?e, "cron: crawl-metrics reaper failed"),
}
if let Err(e) = write_last_tick(pool, Utc::now()).await {
tracing::warn!(?e, "cron: persist last_metadata_tick_at failed");
}