Repository navigation
Conversation
Draft
1 of 3 tasks
`Sentry.cron.instrumentBullMQWorker(worker)` sends check-ins for every job the worker runs from a job scheduler, using the scheduler id as the monitor slug and its `pattern` or `every` as the monitor schedule. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
wedamija
force-pushed
the
danf/bullmq-cron-monitors
branch
from
October 20, 2026 00:51
dd87bd3 to
b7b621e
Compare
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…onitors-merge # Conflicts: # pnpm-lock.yaml
Contributor
size-limit report 📦Compared: 546d46d (PR test merge using danf/shared-cron-converter at 084855e) Against: c491307 (danf/shared-cron-converter) · base run #65764
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 10 not successful, 45 successful. See the run.
Successful checks
|
# Conflicts: # dev-packages/node-integration-tests/package.json # pnpm-lock.yaml
The BullMQ tracing suite from develop also binds 6384.
With BullMQTelemetry, the worker emits `active` before the job's process span starts, so the in_progress check-in linked to the previous job's trace. Sentry keeps that trace for the check-in. Send it from the processor instead, and add an integration test that runs a job scheduler with both enabled.
instrumentBullMQWorker only monitors job schedulers whose schedule Sentry can represent.
@SentryCron, Sentry.cron.* and nodeCronIntegration each turned cron expressions into monitor configs on their own. They now all use cronExpressionToMonitorConfig from @sentry/server-utils, so they can't drift apart.
…onverter # Conflicts: # packages/node/src/cron/cron.ts # packages/node/src/cron/node-schedule.ts # packages/server-utils/src/index.ts # packages/server-utils/src/utils/cronMonitoring.ts # packages/server-utils/test/utils/cronMonitoring.test.ts
…onitors # Conflicts: # packages/node/src/cron/index.ts
cron ignores a day field that lists every day. cron-parser counts duplicate values instead, and reads a weekday range that ends on 7 as including Sunday. Each scheduler now gets its own dialect, so cron-parser quirks no longer drop cron schedules and cron rules no longer send configs that node-schedule reads differently.
…nges The schedulers run `13-13/3` only on the 13th, but Sentry reads it as `13/3`.
… supports cron and cron-parser reject full names like `sunday` and some nicknames like `@annually`, so they now send no monitor config either. node-cron accepts full names.
instrumentNodeCron can't tell the node-cron version, and before 4.6 node-cron reads ranges like `5-0`, `sat-sun` and `1-7` and some steps differently. It now sends no monitor config for those, like nodeCronIntegration does.
The suites ran per-second jobs, which send no monitor config. They now run a weekday schedule by hand.
…ode-cron 4.6 node-cron before 4.6 reads a step without a range, like `5/10`, as its start.
# Conflicts: # CHANGELOG.md
The cron and cron-parser packages reject ranges like sat-sun, so don't send a monitor config for them.
BullMQ emits `failed` for every attempt, so a retried job sent an error check-in and then opened a second in_progress. The check-in id now comes from the job, so retries and reruns of stalled jobs update the first attempt's check-in, even on another worker, and only the last failure sends an error. Also skips `pattern` schedules when the worker has a custom repeat strategy. Co-Authored-By: Claude <noreply@anthropic.com>
…onitors # Conflicts: # CHANGELOG.md
… danf/bullmq-cron-monitors # Conflicts: # CHANGELOG.md
BullMQ patterns go through `getCronMonitorConfig` with the `cron-parser` dialect, like `node-schedule`. The monitor slug is `<queue>-<scheduler id>`, since scheduler ids are only unique within a queue. Co-Authored-By: Claude <noreply@anthropic.com>
Anchoring the regex keeps it linear on long digit runs (CodeQL js/polynomial-redos).
… danf/bullmq-cron-monitors
…egration Adding the integration is the opt-in, and it monitors every BullMQ Worker without a per-worker call. It lives in server-utils next to the other cron integrations and hooks the Worker constructor through the runtime diagnostics-channel injection, in CJS and ESM. BullMQ is only in the runtime instrumentation list. In the bundler list, the plugins would force it into bundles, where it can't find the files it starts sandboxed processors from. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Frameworks pass this list to their keep-external option, so BullMQ loads through Node's loader, where the runtime hook instruments it. Co-Authored-By: Claude <noreply@anthropic.com>
A dropped seconds value like 59 in '59 0 9 * * *' leaves about a second of slack against Sentry's default 1-minute margin. @SentryCron keeps a larger margin set by the user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… have Sentry rejects schedules like '0 9 31 2,4 *', which cron-parser runs on the day of week. A fuzz of cron-parser 4 and 5 against cronsim found no other differences, so the cron-parser dialect covers both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`bun run` can't inject the worker channel, and the bundler plugins don't instrument BullMQ, so the integration would never send a check-in on Bun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BullMQ 6 is npm latest and uses cron-parser 5, which reads the converted expressions like cron-parser 4 (fuzzed against cronsim) but ignores `utc` and `nthDayOfWeek`. BullMQ 5 reads `nthDayOfWeek` like `#n`, so it's sent that way when that's exact and skipped otherwise. Legacy repeatable jobs are told apart from job schedulers by `repeat.key` or by their key matching the name and repeat options, so scheduler ids that look like hashes or have colons are monitored. The reason a scheduler isn't monitored is logged once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… danf/bullmq-cron-monitors
…iber Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ribers get unknown Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…common key hashes A queue's repeatKeyHashAlgorithm isn't reachable from the worker, so legacy keys hashed with md5, sha1, sha256 or sha512 are recognized too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s logging Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…meout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sentry's upsert overwrites every field a check-in sends, so an automatic margin would replace one set in Sentry. @SentryCron sends only the margin passed to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ERNAL_ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Part of a series adding automatic Crons monitoring for the most-used job schedulers in each SDK. Check-ins for a monitor that doesn't exist yet are dropped, so today each monitor has to be created by hand with its schedule copied from the code. Sending the job's schedule as the monitor config lets Sentry create the monitor and keep it in sync.
This adds
bullmqJobSchedulerIntegration, which sends check-ins for the jobs every BullMQ worker (5.16.0 to 6.x) runs from a job scheduler, with<queue>-<scheduler id>as the monitor slug and the scheduler'spatternoreveryas the schedule. Adding the integration is the opt-in, so no per-worker call is needed; schedulers Crons can't express aren't monitored, and a retried job keeps one check-in.BullMQ is only in the runtime instrumentation list: the bundler plugins force listed packages into the bundle, where BullMQ can't find the files it starts sandboxed processors from. That also means
bun runcan't instrument it, so@sentry/bundoesn't export the integration.Stacked on #25918.
Docs: getsentry/sentry-docs#20053