From 1a5abe5048c8a8585db0819c0d147d19e5f88a02 Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Fri, 16 Oct 2026 17:55:45 -0700 Subject: [PATCH 1/3] docs(js): Document cronJobIntegration for Crons Co-Authored-By: Claude --- ...-crons-automatic-crons-instrumentation.mdx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/includes/javascript-crons-automatic-crons-instrumentation.mdx b/includes/javascript-crons-automatic-crons-instrumentation.mdx index 52e2d314403686..dfd6e29931c98e 100644 --- a/includes/javascript-crons-automatic-crons-instrumentation.mdx +++ b/includes/javascript-crons-automatic-crons-instrumentation.mdx @@ -25,6 +25,41 @@ const job = CronJobWithCheckIn.from({ }); ``` +#### Monitor All Named Jobs + +Requires SDK version `11.5.0` or higher and `cron` version `4.3.0` or higher. + +Instead of wrapping `CronJob`, you can add `cronJobIntegration` to monitor every job that has a `name`: + +```JavaScript +Sentry.init({ + dsn: "___PUBLIC_DSN___", + integrations: [ + Sentry.cronJobIntegration({ + excludeJobs: ["cleanup-temp-files", /^debug-/], // Optional. + }), + ], +}); +``` + +```JavaScript +import { CronJob } from "cron"; + +CronJob.from({ + name: "daily-report", + cronTime: "0 30 9 * * 1-5", + timeZone: "Europe/Vienna", + onTick: sendReport, + start: true, +}); +``` + +The monitor slug is the job `name`. Jobs without a `name`, and jobs that run once at a date, aren't monitored. `excludeJobs` skips jobs whose name matches a string exactly or a regular expression. + +Each check-in sends the schedule and time zone (your server's time zone if `timeZone` isn't set). Schedules that can't be expressed in the Crons schedule format (for example, a job that runs every 10 seconds), and jobs with a `utcOffset`, check in without a monitor config, so create those monitors in Sentry first. + +In NestJS, use the Nest integration's `monitorCronJobs` option instead, because `@nestjs/schedule` runs `@Cron()` methods as named `cron` jobs. + ### Node Cron Requires SDK version `7.92.0` or higher. From 102aaafce76507781cf0c7f5ca8c5eb01b84555c Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Mon, 19 Oct 2026 17:49:39 -0700 Subject: [PATCH 2/3] docs(js): Recommend monitoring all cron jobs first Co-Authored-By: Claude --- ...-crons-automatic-crons-instrumentation.mdx | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/includes/javascript-crons-automatic-crons-instrumentation.mdx b/includes/javascript-crons-automatic-crons-instrumentation.mdx index db7418affcce54..ecc8944f57808f 100644 --- a/includes/javascript-crons-automatic-crons-instrumentation.mdx +++ b/includes/javascript-crons-automatic-crons-instrumentation.mdx @@ -2,34 +2,11 @@ If you're using the [`cron`](https://www.npmjs.com/package/cron), [`node-cron`]( ### Cron -Requires SDK version `7.92.0` or higher. - -Use `Sentry.cron.instrumentCron` to instrument the `CronJob` constructor or `CronJob.from` method in the [`cron`](https://www.npmjs.com/package/cron) library. Pass the name of the cron monitor as a second argument to the function. - -```JavaScript -import { CronJob } from "cron"; - -const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, "my-cron-job"); - -// use the constructor -const job = new CronJobWithCheckIn("* * * * *", () => { - console.log("You will see this message every minute"); -}); - -// or from method -const job = CronJobWithCheckIn.from({ - cronTime: "* * * * *", - onTick: () => { - console.log("You will see this message every minute"); - }, -}); -``` - #### Monitor All Named Jobs Requires SDK version `11.5.0` or higher and `cron` version `4.3.0` or higher. -Instead of wrapping `CronJob`, you can add `cronJobIntegration` to monitor every job that has a `name`: +We recommend adding `cronJobIntegration`, which monitors every job that has a `name`: ```JavaScript Sentry.init({ @@ -60,6 +37,33 @@ Each check-in sends the schedule and time zone (your server's time zone if `time In NestJS, use the Nest integration's `monitorCronJobs` option instead, because `@nestjs/schedule` runs `@Cron()` methods as named `cron` jobs. +#### Monitor Specific Jobs + +Requires SDK version `7.92.0` or higher. + +Use `Sentry.cron.instrumentCron` to instrument the `CronJob` constructor or `CronJob.from` method in the [`cron`](https://www.npmjs.com/package/cron) library. Pass the name of the cron monitor as a second argument to the function. + +```JavaScript +import { CronJob } from "cron"; + +const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, "my-cron-job"); + +// use the constructor +const job = new CronJobWithCheckIn("* * * * *", () => { + console.log("You will see this message every minute"); +}); + +// or from method +const job = CronJobWithCheckIn.from({ + cronTime: "* * * * *", + onTick: () => { + console.log("You will see this message every minute"); + }, +}); +``` + +`cronJobIntegration` skips jobs created with `instrumentCron`, so using both doesn't send duplicate check-ins. + ### Node Cron #### Monitor All Named Tasks From b587c80f5bf92bd399925a72443569a075cd9e4c Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Tue, 20 Oct 2026 10:49:47 -0700 Subject: [PATCH 3/3] docs(js): Require the next SDK release for cronJobIntegration Co-Authored-By: Claude --- includes/javascript-crons-automatic-crons-instrumentation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/javascript-crons-automatic-crons-instrumentation.mdx b/includes/javascript-crons-automatic-crons-instrumentation.mdx index cd2581eb42e2a4..858bf540398837 100644 --- a/includes/javascript-crons-automatic-crons-instrumentation.mdx +++ b/includes/javascript-crons-automatic-crons-instrumentation.mdx @@ -4,7 +4,7 @@ If you're using the [`cron`](https://www.npmjs.com/package/cron), [`node-cron`]( #### Monitor All Named Jobs -Requires SDK version `11.5.0` or higher and `cron` version `4.3.0` or higher. +Requires SDK version `11.9.0` or higher and `cron` version `4.3.0` or higher. We recommend adding `cronJobIntegration`, which monitors every job that has a `name`: