Repository navigation
feat(sentry): watch cron jobs: Sentry Crons check-ins and ping URLs on the Crons tab and over MCP - #385
Merged
Conversation
…sed and timed-out runs on the Crons tab and over MCP
The Crons tab of the bundled UI got 404 from `/api/crons` and stayed hidden. Trap now takes `check_in` envelope items, the Sentry cron HTTP endpoint `/api/{id}/cron/{slug}/{key}/` and the ping URLs `/ping/{slug}[/start|/fail]` the job page shows, upserts the monitor from its `monitor_config` as Sentry does (a field left out keeps its value, `null` resets it), and keeps 200 monitors with 100 runs each in the telemetry store. While an event consumer runs, the main loop checks them about once a second: a slot without a check-in within the margin is missed, a run in progress past its max runtime times out, and slots that fell while the loop did not run (the machine slept) make one unknown row; each change reaches the UI by the `sentry.stored` push of kind `cron`.
Crontabs and intervals follow the Sentry spec and real cron rather than the Go server: slots are wall times of the monitor's zone, a time skipped by clocks going forward is no slot and one they repeat is one slot of a fixed-hour job, intervals of a day or longer keep the wall time and clamp month ends, slugs are slugified as Sentry does, margin and max runtime are 1 to 40 320 minutes, an `in_progress` again extends a run, the next slot counts from the start of the run, and each run keeps the timeout it began with. Clearing the Sentry section deletes runs and keeps the monitors; `DELETE /api/crons/{slug}` deletes one. `/api/projects` lists the projects of monitors too, `list_crons` reads them over MCP, the console prints a line per check-in with the reason a config was ignored, and `trap test` sends SDK and ping check-ins.
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #385 +/- ##
==========================================
+ Coverage 80.78% 81.07% +0.29%
==========================================
Files 441 453 +12
Lines 17813 18490 +677
==========================================
+ Hits 14390 14991 +601
- Misses 3423 3499 +76 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… downtimes, late runs and clock changes An interval is 1 minute to 10 years: a huge value from an SDK made `next()` throw in the main loop, or return the same slot so `miss()` looped forever. The checker now stops expecting a monitor whose schedule does not move on, and a failure of one monitor or of a listener no longer stops Trap. A downtime makes one `unknown` row per monitor whatever the checks after it, and the next slot is the first after Trap woke up, so a long sleep takes one step per monitor instead of one per slot. The next slot counts from the start of the newest run, so an older run that ends late no longer moves it back into a false miss; a crontab run that starts less than a minute (and less than the margin and a quarter of the period) before its slot counts for that slot, for hosts whose clock runs ahead. Interval slots count from their anchor, so a daily slot moved by a change of clocks does not move the ones after it; the crontab search stops at each change of clocks, as Pacific/Chatham jumps at :45; a clock set back keeps the checks going; a heartbeat extends a run by the max runtime the run started with. `?` is a whole day field only. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…eeps and `list_crons` returns A ping body of any size is taken and keeps its last 10 KB; the cron HTTP API keeps its 1 MB limit. An environment keeps 64 characters, a trace ID only 32 hex digits, and the output of all runs 8 MB. `list_crons` returns the last 1 024 bytes of an output, and it and the web UI API find a slug as the job sent it. A `monitor_config` that is no object gets `400` from the HTTP API and is ignored with a warning from an SDK; a `check_in` item that is no object says why it is dropped. The MCP instructions name `list_feedback` and `list_crons`, and the docs and the skill say that `/ping/...` is no HTTP dump and that port 8000 takes pings. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…f its changes, and take an early run by the gap before its slot A monitor whose schedule fails, a check that fails and a listener that throws are logged in the console instead of passing silently, and a listener that throws for one project no longer keeps the other projects and listeners from being told of their timed-out and missed runs. A run that starts before a crontab slot counts for that slot only if the slot before is more than four times as far back, so with `0,1 * * * *` a run late for :00 no longer hides a missed :01. A JSON list sent as a check-in says it is no object. The docs and the skill state the 64M limit of a chunked ping body, the max runtime a heartbeat keeps, and the skill now has the clock-skew rule, the next slot after a downtime, the 10-year interval cap, the caps of an environment and a trace ID and the 1 MB limit of the cron HTTP API. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…r one slot only A listener that throws on stored traces, logs, metrics, feedback or check-ins is logged and the next listener is still told, as for the cron checks. A run that starts shortly before a crontab slot while the slot before still waits for its run is the run of that slot, so with `* * * * *` a run at 12:00:50 after none for 12:00 no longer skips 12:01. The docs and the skill say "less than a minute before", which slot a late run stays with, and that only the cron HTTP API rejects a `monitor_config` that is no object. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/mcp.md # docs/sentry.md # docs/web-ui.md # skills/trap/references/mcp.md # src/Module/Sentry/Module.php # tests/Unit/Module/Frontend/UiControllersTest.php # tests/Unit/Module/Mcp/Protocol/McpServerTest.php
roxblnfk
marked this pull request as ready for review
November 24, 2026 06:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍 What was changed
GET /api/crons,GET /api/crons/{slug}/checkinsin the shape frontend 1.42.0 reads,DELETE /api/crons/{slug}, and thesentry.storedpush of kindcron. The tab is always shown now; its job page shows the runs, output, traces and ping URLs.check_inenvelope items, the Sentry cron HTTP endpoint/api/{id}/cron/{slug}/{key}/, or the ping URLs/ping/{slug},/start,/fail(?schedule=&tz=&margin=&max_runtime=&project=, body kept as the job's output, last 10 KB). The monitor is upserted frommonitor_configas Sentry does.list_cronsMCP tool, a console line per check-in (no "no renderer" line),trap testsends SDK and ping check-ins,/api/projectslists the projects of monitors too./ping/...requests are no longer HTTP dumps.How it works
in_progress) or closes it bycheck_in_id; a ping without an ID closes the newest started ping run. The next slot is the first after the start of the last run, or after now when that has passed.missed(not while a run is in progress); a run past its max runtime →timeout; slots that fell while the loop did not run (machine asleep) → oneunknownrow.Review notes
Deliberate differences from buggregator/server 2.14, which was used only for the wire contract:
*-hour jobs); interval of days or more keeps the wall time and clamps month ends (Jan 31 + 1 month = Feb 28).@everyis rejected, as Sentry does.Reports Send→reports-send, max 50) instead of rejected; margin and max runtime are 1–40 320 minutes (Sentry's range), not ≥ 0.in_progressextends the run's max runtime (Sentry heartbeat); each run keeps the timeout it started with; a finished run is final.PUT /api/crons/{slug}(the UI does not call it; ping query andmonitor_configconfigure a monitor).failure_issue_threshold/recovery_thresholdare ignored since Trap raises no issues.Checklist
Run.phperrors), structarmed, markdownlinttrap -p18311 --ui=18311 --mcp=18311, envelopes, cron HTTP endpoint and pings; a 1-minute interval job went missed, a 1-minute ping run timed out; Crons tab and every job page in headless Chromium with no errors but the known/api/updateand queues 404s; a new ping showed on the open tab without a reload;list_cronsover MCPDocumentation
docs/sentry.md(new Crons section),docs/web-ui.md,docs/mcp.md,docs/cli.md,docs/http-dump.md, and thetrapskill (SKILL.md,references/mcp.md,references/integrations.md).