Set Up Crons
Sentry Crons allows you to monitor the uptime and performance of any scheduled, recurring job in your application.
Once implemented, it'll allow you to get alerts and metrics to help you solve errors, detect timeouts, and prevent disruptions to your service.
If you are using Hangfire, please see how to setup monitoring for Hangfire jobs.
- Use our getting started guide to install and configure the Sentry .NET SDK (min 4.2.0) for your recurring job.
- Create and configure your first Monitor.
Check-in monitoring allows you to track a job's progress by completing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed).
// 🟡 Notify Sentry your job is running:
var checkInId = SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.InProgress);
// Execute your scheduled task here...
// 🟢 Notify Sentry your job has completed successfully:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Ok, checkInId);
If your job execution fails, you can notify Sentry about the failure:
// 🔴 Notify Sentry your job has failed:
SentrySdk.CaptureCheckIn("<monitor-slug>", CheckInStatus.Error, checkInId);
When your recurring job fails to check in (missed), runs beyond its configured maximum runtime (failed), or manually reports a failure, Sentry will create an error event with a tag to your monitor.
To receive alerts about these events:
- Navigate to Alerts in the sidebar.
- Create a new alert and select "Issues" under "Errors" as the alert type.
- Configure your alert and define a filter match to use:
The event's tags match {key} {match} {value}
.
Example: The event's tags match monitor.slug equals my-monitor-slug-here
Learn more in Issue Alert Configuration.
Crons 对签到实施速率限制以防止滥用和资源过度使用。具体来说,每个现有监控环境每分钟最多只能发送 6 个签到。此限制按项目强制执行,意味着该速率限制适用于给定项目中的所有监控环境。您可以在 Usage Stats 页面检查是否有任何签到被丢弃。
为了避免签到被丢弃,重要的是要高效地管理和分配签到,使其在速率限制内。这将有助于保持准确的监控,并确保所有关键