Observability: Cron enhancements
维护者通常 1 天内回复
@vprashrex 已经在做这个了。
开始于 2026年10月23日。
评估
这个 Issue 还没有评估数据。
描述
Is your feature request related to a problem?
The current design excludes /cron/* endpoints from tracing, making it difficult to track what a cron run processes since Celery tasks appear as separate root traces. Additionally, failing runs incorrectly report as successful due to the handling of exceptions in process_all_pending_evaluations.
Describe the solution you'd like
- Trace only when there's actual work, opening spans after polling for pending runs while keeping
/cronexcluded. - Implement error monitoring for runs that end with
status: errorto correctly report failures in Sentry. - Include span attributes like pending run count and processing status for clarity.
- Ensure consistent timezone settings across monitor configurations.
- Create tests to validate span existence with pending runs and error reporting for failed runs.
Original issue
Problem
/cron/* endpoints are excluded from tracing on purpose, so an idle cron run doesn't create a trace every minute. The downside is that Celery tasks the cron enqueues (send_eval_completion_notification, fast-eval barriers, iteration resumes) have no parent span and each one shows up as its own root trace. You can't see in one place what a cron run actually processed.
There's a second gap: process_all_pending_evaluations catches every exception and returns {"status": "error"}, so the @sentry_sdk.monitor check-in still reports OK when the run failed.
What we'll do
- Trace only when there's real work. Keep
/cronexcluded. Open a span (evaluation.cron.poll,evaluation.cron.poll_stt/poll_tts, plus fast-barrier and iteration-resume dispatch) only after a poll finds pending runs. Tasks enqueued inside nest under it; idle runs produce no trace.crud/evaluations/processing.py→poll_all_pending_evaluationscrud/evaluations/cron_utils.py→poll_all_pending_evaluations_by_typecrud/evaluations/cron.py→ fast-eval barrier and iteration-resume dispatch
- Report real failures to the cron monitor. When a run ends with
status: error, send an error check-in (re-raise, orcapture_checkin(..., status=MonitorStatus.ERROR)), so Sentry marks the run failed instead of OK. - Span attributes worth having: pending run count, processed / failed / still-processing counts, so a cron trace explains itself.
- Consistent timezone across monitor configs (evaluations uses
UTC, the othersAsia/Kolkata). - Tests: span exists only when there are pending runs; failed run sends an error check-in.
What Sentry Crons gives us (besides uptime)
@monitor/with monitor(...)withmonitor_configto create or update the monitor from code (already used inapi/routes/cron.py).monitor_config:schedule(crontab or interval),checkin_margin,max_runtime,failure_issue_threshold,recovery_threshold,timezone.- Check-in statuses
in_progress/ok/error, plus manualcapture_checkin(monitor_slug, check_in_id, status)for jobs that can't use the decorator. - Missed, failed and timed-out runs become Issues, with per-monitor alerting.
- Monitor environments: check-ins are tracked per environment (production / staging).
CeleryIntegration(monitor_beat_tasks=True, exclude_beat_tasks=[...])auto-monitors Celery Beat tasks. Not used today because our crons are HTTP-triggered, but an option if they move to Beat.
Out of scope
Uptime monitors, and moving crons to Celery Beat.
- 主要语言
- Python
- 星标
- 18
- 派生
- 11
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 33
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ProjectTech4DevAI/kaapi-backend 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
ProjectTech4DevAI/kaapi-backend#889 ·
维护者通常 1 天内回复
-
Storage Management: Delete S3 audio files可能已有人在做 @Prajna1999 于 1 天前认领。 未关闭
ProjectTech4DevAI/kaapi-backend#1308 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Sentry: Add module and version tags可能已有人在做 @vprashrex 于 2 天前认领。 未关闭
ProjectTech4DevAI/kaapi-backend#1305 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Otel: Standardize key constants可能已有人在做 @vprashrex 于 6 天前认领。 未关闭
ProjectTech4DevAI/kaapi-backend#1294 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Chabot: Server-side chatbot state management可能已有人在做 @Ayush8923 于 6 天前认领。 未关闭
ProjectTech4DevAI/kaapi-backend#1278 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 ProjectTech4DevAI/kaapi-backend 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
btclib-org/btclib-node#2083 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
Gathin23/cleanyourtv#2089 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
jxxghp/MoviePilot#7212 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
cli dx rust
难度 2/5 1-3 小时 新手友好度 85/100
NekomyaDev/nudge#278 ·
维护者通常 1 天内回复