Repository navigation
Conversation
Opt-in via UseSentry(o => o.SendRecurringJobSchedule = true). The in-progress check-in of a recurring job carries the job's cron and time zone so Sentry can create the monitor. Unsupported schedules fall back to a check-in without config. Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5665 +/- ##
==========================================
+ Coverage 74.93% 75.36% +0.43%
==========================================
Files 515 517 +2
Lines 18975 19061 +86
Branches 3695 3716 +21
==========================================
+ Hits 14219 14366 +147
+ Misses 3876 3827 -49
+ Partials 880 868 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Check the crontab up front so the check-in goes out in a single call instead of relying on the hub to swallow an exception from Interval. The validator is shared with Sentry.Hangfire as a linked source file, since the unsigned assembly can't see Sentry's internals. Read the job through GetRecurringJobs, look up time zones with FindSystemTimeZoneById on .NET 6+, and add tests for UTC, unknown zones, deleted jobs, the UseSentry overload, and a real recurring job. Co-Authored-By: Claude <noreply@anthropic.com>
The linux-musl CI containers have no time zone database, so lookups of Europe/Berlin and Etc/UTC fail there. Co-Authored-By: Claude <noreply@anthropic.com>
Hangfire runs a job only on days that match both the day-of-month and day-of-week fields, while Sentry runs it on days that match either unless one of them starts with '*'. Don't send those schedules, nor ones with a reversed range such as 5-1 or SAT-SUN, which Sentry rejects. Co-Authored-By: Claude <noreply@anthropic.com>
Jobs are only monitored when they have [SentryMonitorSlug], so sending the recurring job's schedule lets Sentry create or update the monitor, like the Spring and Quartz integrations. Set SendRecurringJobSchedule to false to keep managing the schedule in Sentry. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Overall, looks good - I just have one question/suggestion re consistent naming.
The only other thing to note is that if someone deletes a monitor but leaves [SentryMonitorSlug] on the job, the monitor will be recreated on the next run... That's probably OK and better than a monitor that doesn't get created (which we have now). It means people have to remove the slug attribute and redeploy before they can remove a monitor. Any alternative technical workaround would probably have to be a bit more convoluted (leave some trace of the monitor having been deleted on the server).
The final check-in reused the ID returned for the in-progress one, which is empty when that one isn't captured. Create the ID up front, send it with the in-progress check-in, and store it in the job's items as before. Co-Authored-By: Claude <noreply@anthropic.com>
On re-creating deleted monitors: agreed, that's inherent to upsert and works the same in the other SDKs. One other option here is to disable the monitor in Sentry, rather than deleting it. Since the monitor still exists, rather than recreating it the checkins will just be dropped. I can add that to the docs in this pr: getsentry/sentry-docs#19781 |
Matches SentryQuartzOptions.SendMonitorConfig. Co-Authored-By: Claude <noreply@anthropic.com>
Description
Adds a
SendMonitorConfigoption to the Hangfire integration. When it's on, the in-progress check-in of a recurring job includes the job's cron and time zone as the monitor config, so Sentry creates the monitor or updates its schedule. The slug still comes from[SentryMonitorSlug].It's on by default. To turn it off:
When the schedule can't be represented exactly in Sentry (seconds other than a fixed value, day fields Hangfire combines differently, a time zone with no IANA ID), the check-in goes out without a config, as today, rather than with a schedule that would cause false missed-check-in alerts.
Hangfire jobs are only monitored when they already have
[SentryMonitorSlug], so the user has opted in to monitoring, and the recurring job already knows its schedule. Sending it by default lets Sentry create or update the monitor, the same as the Spring and Quartz integrations. On upgrade, existing monitors get their schedule and time zone from the recurring job; setSendMonitorConfig = falseto keep managing them in Sentry.Motivation
Check-ins for a monitor that doesn't exist yet are dropped, so today every Hangfire monitor has to be created by hand, with its schedule copied from the recurring job. The schedule is already in Hangfire, so the SDK can send it.
Testing
ServerFilterTestsandHangfireTests.Docs: getsentry/sentry-docs#19781