From c85e262d31e73f8ece7f9db0d458b5e386700e51 Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Fri, 16 Oct 2026 17:35:25 -0700 Subject: [PATCH 1/3] docs(nestjs): Document monitorCronJobs for @Cron methods Co-Authored-By: Claude --- includes/nestjs-sentry-cron-decorator.mdx | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/includes/nestjs-sentry-cron-decorator.mdx b/includes/nestjs-sentry-cron-decorator.mdx index 1c678107a0de9..755b8c5889c36 100644 --- a/includes/nestjs-sentry-cron-decorator.mdx +++ b/includes/nestjs-sentry-cron-decorator.mdx @@ -56,3 +56,27 @@ The monitor is created, and billed, on the first run. Each check-in overwrites t A six-field expression is sent without its seconds field if that field is a single number, such as `0 30 9 * * *`. Presets such as `@daily` and `@weekly` are sent too. Sub-minute schedules, `Date` values, `utcOffset`, month numbers (use names such as `MAY`; steps such as `*/3` work), a `*/n` or full-range day field (such as `1-31`) combined with the other day field, and time zones that aren't IANA names send no monitor config, including any other options you pass. In those cases, pass a full monitor config to `@SentryCron` or create the monitor in Sentry first. To send check-ins without a monitor config, pass `{ fromCronDecorator: false }`. + +### Monitor All `@Cron` Methods + + + +To monitor every `@Cron` method without adding `@SentryCron` to each one, enable `monitorCronJobs` on the Nest integration: + +```typescript {filename:instrument.ts} +import * as Sentry from "@sentry/nestjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + integrations: [ + Sentry.nestIntegration({ + monitorCronJobs: true, + excludeCronJobs: ["cleanup-temp-files", /^Debug/], // Optional. + }), + ], +}); +``` + +The monitor slug is the `name` option of `@Cron`, or `ClassName.methodName` if there's no `name`. Set a `name` if your build minifies class names, so the slug doesn't change between deploys. `excludeCronJobs` skips jobs whose slug matches a string exactly or a regular expression. + +Each check-in sends the schedule and time zone of `@Cron`, as described above. Schedules that can't be expressed in the Crons schedule format (for example, a job that runs every 10 seconds) check in without a monitor config, so create those monitors in Sentry first. `@Cron` with a `Date` runs once and isn't monitored. Methods that also have `@SentryCron` keep the slug and options you pass to it. From 18c3e26f5ac1323c4894191aa3babb4fb690583b Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Mon, 19 Oct 2026 17:50:18 -0700 Subject: [PATCH 2/3] docs(nestjs): Recommend monitoring all @Cron methods first Co-Authored-By: Claude --- includes/nestjs-sentry-cron-decorator.mdx | 53 ++++++++++++----------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/includes/nestjs-sentry-cron-decorator.mdx b/includes/nestjs-sentry-cron-decorator.mdx index 755b8c5889c36..6f13bc0ba1ac3 100644 --- a/includes/nestjs-sentry-cron-decorator.mdx +++ b/includes/nestjs-sentry-cron-decorator.mdx @@ -1,3 +1,29 @@ +### Monitor All `@Cron` Methods + + + +We recommend enabling `monitorCronJobs` on the Nest integration, which monitors every `@Cron` method without adding `@SentryCron` to each one: + +```typescript {filename:instrument.ts} +import * as Sentry from "@sentry/nestjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + integrations: [ + Sentry.nestIntegration({ + monitorCronJobs: true, + excludeCronJobs: ["cleanup-temp-files", /^Debug/], // Optional. + }), + ], +}); +``` + +The monitor slug is the `name` option of `@Cron`, or `ClassName.methodName` if there's no `name`. Set a `name` if your build minifies class names, so the slug doesn't change between deploys. `excludeCronJobs` skips jobs whose slug matches a string exactly or a regular expression. + +Each check-in sends the schedule and time zone of `@Cron`, as described in [Monitor Config From `@Cron`](#monitor-config-from-cron). Schedules that can't be expressed in the Crons schedule format (for example, a job that runs every 10 seconds) check in without a monitor config, so create those monitors in Sentry first. `@Cron` with a `Date` runs once and isn't monitored. + +### Monitor Specific Methods + The NestJS SDK includes a `@SentryCron` decorator that can be used to augment the native NestJS `@Cron` decorator to send check-ins to Sentry before and after each cron job run. @@ -29,8 +55,9 @@ export class MyCronService { } ``` +`monitorCronJobs` skips methods that have `@SentryCron`, so they check in once, with the slug and options you pass to `@SentryCron`. -### Monitor Config From `@Cron` +#### Monitor Config From `@Cron` @@ -56,27 +83,3 @@ The monitor is created, and billed, on the first run. Each check-in overwrites t A six-field expression is sent without its seconds field if that field is a single number, such as `0 30 9 * * *`. Presets such as `@daily` and `@weekly` are sent too. Sub-minute schedules, `Date` values, `utcOffset`, month numbers (use names such as `MAY`; steps such as `*/3` work), a `*/n` or full-range day field (such as `1-31`) combined with the other day field, and time zones that aren't IANA names send no monitor config, including any other options you pass. In those cases, pass a full monitor config to `@SentryCron` or create the monitor in Sentry first. To send check-ins without a monitor config, pass `{ fromCronDecorator: false }`. - -### Monitor All `@Cron` Methods - - - -To monitor every `@Cron` method without adding `@SentryCron` to each one, enable `monitorCronJobs` on the Nest integration: - -```typescript {filename:instrument.ts} -import * as Sentry from "@sentry/nestjs"; - -Sentry.init({ - dsn: "___PUBLIC_DSN___", - integrations: [ - Sentry.nestIntegration({ - monitorCronJobs: true, - excludeCronJobs: ["cleanup-temp-files", /^Debug/], // Optional. - }), - ], -}); -``` - -The monitor slug is the `name` option of `@Cron`, or `ClassName.methodName` if there's no `name`. Set a `name` if your build minifies class names, so the slug doesn't change between deploys. `excludeCronJobs` skips jobs whose slug matches a string exactly or a regular expression. - -Each check-in sends the schedule and time zone of `@Cron`, as described above. Schedules that can't be expressed in the Crons schedule format (for example, a job that runs every 10 seconds) check in without a monitor config, so create those monitors in Sentry first. `@Cron` with a `Date` runs once and isn't monitored. Methods that also have `@SentryCron` keep the slug and options you pass to it. From 7c45971d802b213b0f287ead0486d82b3a0e247c Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Tue, 20 Oct 2026 10:49:58 -0700 Subject: [PATCH 3/3] docs(nestjs): Require the next SDK release for monitorCronJobs Co-Authored-By: Claude --- includes/nestjs-sentry-cron-decorator.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/nestjs-sentry-cron-decorator.mdx b/includes/nestjs-sentry-cron-decorator.mdx index 6f13bc0ba1ac3..87e221574ce2a 100644 --- a/includes/nestjs-sentry-cron-decorator.mdx +++ b/includes/nestjs-sentry-cron-decorator.mdx @@ -1,6 +1,6 @@ ### Monitor All `@Cron` Methods - + We recommend enabling `monitorCronJobs` on the Nest integration, which monitors every `@Cron` method without adding `@SentryCron` to each one: