You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Heartbeat monitoring notifies Sentry of a job's status through one check-in. This setup will only notify you if your job didn't run when expected (missed). If you want to monitor job timeouts, use the `InProgress` check-ins as indicated in the previous section.
25
+
26
+
```csharp
27
+
// Execute your scheduled task...
28
+
29
+
// 🟢 Notify Sentry your job completed successfully:
30
+
SentrySdk.CaptureCheckIn(
31
+
"<monitor-slug>",
32
+
CheckInStatus.Ok,
33
+
// Optionally annotate the check-in with the job duration
34
+
duration: TimeSpan.FromSeconds(10)
35
+
);
36
+
```
37
+
38
+
If your job execution fails, you can:
39
+
40
+
```csharp
41
+
// 🔴 Notify Sentry your job has failed:
42
+
SentrySdk.CaptureCheckIn(
43
+
"<monitor-slug>",
44
+
CheckInStatus.Error,
45
+
duration: TimeSpan.FromSeconds(10)
46
+
);
47
+
```
48
+
49
+
## Upserting Cron Monitors
50
+
51
+
You can create and update your Monitors programmatically with code
52
+
rather than [creating and configuring them in Sentry.io](https://sentry.io/issues/alerts/new/crons/).
53
+
54
+
```csharp
55
+
// 🟡 Notify Sentry your job is running:
56
+
varcheckInId=SentrySdk.CaptureCheckIn(
57
+
"<monitor-slug>",
58
+
CheckInStatus.InProgress,
59
+
configureMonitorOptions: options=>
60
+
{
61
+
// Use a crontab schedule (every 10 minutes)
62
+
options.Interval("*/10 * * * *");
63
+
options.CheckInMargin=TimeSpan.FromMinutes(5);
64
+
options.MaxRuntime=TimeSpan.FromMinutes(15);
65
+
options.TimeZone="Europe/Vienna";
66
+
options.FailureIssueThreshold=2;
67
+
options.RecoveryThreshold=5;
68
+
});
69
+
70
+
// Execute your scheduled task here...
71
+
72
+
// 🟢 Notify Sentry your job has completed successfully:
0 commit comments