Skip to content

feat(quartz): Add an option to monitor all scheduled jobs - #5741

Open
wedamija wants to merge 58 commits into
mainfrom
danf/quartz-bulk-cron
Open

wedamija wants to merge 58 commits into
mainfrom
danf/quartz-bulk-cron

Conversation

@wedamija

@wedamija wedamija commented Oct 17, 2026 •

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.

This adds SentryQuartzOptions.MonitorAllJobs, which monitors every scheduled job without adding [SentryMonitorSlug] to each job class, and ExcludedJobs to skip some by name, full key or regex. The monitor slug comes from the job key. Jobs with [SentryMonitorSlug] keep their own settings. Off by default.

services.AddQuartz(quartz =>
{
    quartz.AddSentry(options =>
    {
        options.MonitorAllJobs = true;
        options.ExcludedJobs.Add("reports.Adhoc");
        options.ExcludedJobs.Add(new Regex(@"^maintenance\."));
    });
});

Only runs fired by a cron trigger or a repeating simple trigger are monitored, so one-off runs like TriggerJob are skipped. Schedules Sentry can't represent, triggers with a calendar and jobs with several triggers check in without a config.

Stacked on #5505, through the danf/quartz-5505-rebased branch since that PR's head is on a fork.

michaelmairegger and others added 30 commits October 8, 2026 11:14
… dependencies and streamlining SentryCronJobListener options handling
… collection parameter and streamlining option configuration
…dSentryScope method, update SentryMetricsMiddleware to support configurable options
The format-code workflow can't push its auto-fix to a fork branch, so it
fails the check instead. Applying the fix here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every package needs a name/packageUrl/mainDocsUrl entry so craft can create
its registry entry on first publish; a missing `name` fails the whole
registry target rather than just that package.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
wedamija and others added 3 commits October 13, 2026 14:52
…lug attribute

Quartz logs a job's exception only after the middleware chain has
returned, so the logged error lost the job's scope and trace. Capture it
inside the scope again; the SDK drops the duplicate from the log.

Rename SentryCronMonitorSlugAttribute to SentryMonitorSlugAttribute to
match Sentry.Hangfire.

Co-Authored-By: Claude <noreply@anthropic.com>
The AddSentry() remarks still said job exceptions are left to the logging integration. The scope middleware has captured them again since 73e5551.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MonitorAllJobs sends check-ins for every job fired by a cron trigger or a
repeating simple trigger, with the slug of the job's key. ExcludedJobs
skips jobs by name, full key or regex. Jobs with SentryMonitorSlug keep
their settings.

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

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.13%. Comparing base (04cac0d) to head (fde31be).

Files with missing lines Patch % Lines
src/Sentry.Quartz/Core/JobMonitor.cs 90.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5741   +/-   ##
=======================================
  Coverage   76.13%   76.13%           
=======================================
  Files         528      528           
  Lines       19579    19603   +24     
  Branches     3829     3840   +11     
=======================================
+ Hits        14906    14925   +19     
- Misses       3791     3792    +1     
- Partials      882      886    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…schedules

Reads every monitored trigger, cached for a minute, like Sentry.Hangfire. Replaces the check for jobs with several triggers.
@wedamija wedamija changed the title feat(quartz): Add an option to monitor every scheduled job feat(quartz): Add an option to monitor all scheduled jobs Oct 20, 2026
@wedamija
wedamija marked this pull request as ready for review October 20, 2026 17:29
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 20, 2026
wedamija and others added 11 commits October 20, 2026 11:12
A job without an identity has fallen back to its class name with a debug message, not a warning, since fe97276.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picks up #5757, which fixes the Blazor WASM E2E job on Ubuntu 26.04 runners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jobs that MonitorAllJobs covers now count in the shared slug check, so a
job with several triggers on different schedules still drops the
schedule, and their triggers stay in the cached lookup.

Co-Authored-By: Claude <noreply@anthropic.com>
…gers

A job left in a persistent store after its class was renamed or deleted
made the whole trigger read throw, so no monitored job sent its schedule.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…aptured

Co-Authored-By: Claude <noreply@anthropic.com>
…tion on

Quartz's ErrorLogger logs the exception again, wrapped in a
JobExecutionProcessException that the default DeduplicateMode doesn't
unwrap. AddSentry now adds a log entry filter for that entry, to
whichever SentryLoggingOptions the app uses (SentryAspNetCoreOptions
included), when the middleware captured the inner exception.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code

linear-code Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

NET-180

NET-483

wedamija and others added 3 commits October 21, 2026 11:00
Co-authored-by: Ricardo Colombo Oliveira <github@ricoliv.com>
…log filter setup

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@wedamija
wedamija changed the base branch from danf/quartz-5505-rebased to main October 21, 2026 23:02

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

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants