Skip to content

feat(nestjs): Add option to monitor every @Cron method - #25471

Draft
wedamija wants to merge 1 commit into
danf/nestjs-cron-configfrom
danf/nestjs-cron-auto-monitor
Draft

wedamija wants to merge 1 commit into
danf/nestjs-cron-configfrom
danf/nestjs-cron-auto-monitor

Conversation

@wedamija

Copy link
Copy Markdown
Member

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.

Description

Adds monitorCronJobs to nestIntegration. When enabled, every @Cron() method of @nestjs/schedule sends check-ins, with the schedule and time zone of @Cron() as the monitor config (same conversion as @SentryCron in #25013). It is off by default.

Sentry.init({
  dsn: '...',
  integrations: [
    Sentry.nestIntegration({
      monitorCronJobs: true,
      excludeCronJobs: ['cleanup', /^Dev/],
    }),
  ],
});

The slug is the name option of @Cron(), or ClassName.methodName without one. excludeCronJobs matches slugs (strings exactly, or regexes). Methods that also have @SentryCron keep their explicit slug and send one set of check-ins. Schedules Sentry would read differently (for example, a job that runs every 10 seconds) check in without a config. @Cron() with a Date runs once and is not monitored. This uses the @Cron instrumentation of the orchestrion channel injection, so it needs enableRuntimeChannelInjection (on by default).

Testing

Unit tests for slugs, exclusion, @SentryCron in both decorator orders, and error check-ins; an e2e test in nestjs-basic.

Stacked on #25013.

`nestIntegration({ monitorCronJobs: true })` sends check-ins for every
`@Cron()` method, with the schedule from `@Cron()` as monitor config.
The slug is the `@Cron()` name, else `ClassName.methodName`.
`excludeCronJobs` skips jobs; methods with `@SentryCron` keep their slug.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.44 kB - -
@sentry/browser - with treeshaking flags 27.59 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.48 kB - -
@sentry/browser (incl. Tracing) 51.32 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.33 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.31 kB - -
@sentry/browser (incl. Tracing, Replay) 90.95 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.93 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.65 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.65 kB - -
@sentry/browser (incl. Feedback) 46.96 kB - -
@sentry/browser (incl. sendFeedback) 34.5 kB - -
@sentry/browser (incl. FeedbackAsync) 39.6 kB - -
@sentry/browser (incl. Metrics) 30.45 kB - -
@sentry/browser (incl. Logs) 30.74 kB - -
@sentry/browser (incl. Metrics & Logs) 31.39 kB - -
@sentry/react 31.28 kB - -
@sentry/react (incl. Tracing) 53.69 kB - -
@sentry/vue 37.41 kB - -
@sentry/vue (incl. Tracing) 54.23 kB - -
@sentry/svelte 29.47 kB - -
@sentry/remix (Remix 3 client bundle) 55.65 kB - -
CDN Bundle 31.13 kB - -
CDN Bundle (incl. Tracing) 51.87 kB - -
CDN Bundle (incl. Logs, Metrics) 33.37 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.81 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.1 kB - -
CDN Bundle (incl. Tracing, Replay) 89.45 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.42 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.59 kB - -
CDN Bundle - uncompressed 91.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.26 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.53 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 160.21 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.15 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 274.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 280 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.69 kB - -
@sentry/nextjs (client) 56.18 kB - -
@sentry/sveltekit (client) 51.74 kB - -
@sentry/core/server 40.5 kB - -
@sentry/core/browser 13.51 kB - -
@sentry/node 144.64 kB +0.01% +11 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.22 kB - -
@sentry/node - without tracing 93.21 kB +0.02% +14 B 🔺
@sentry/node - without channel injection 122.85 kB +0.01% +7 B 🔺
@sentry/aws-serverless 101.46 kB +0.01% +8 B 🔺
@sentry/cloudflare (withSentry) - minified 208.47 kB - -
@sentry/cloudflare (withSentry) 516.75 kB - -

View base workflow run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant