Skip to content

Commit 2a26f8c

Browse files
adinauergetsantry[bot]shanamatthews
authored
Java CRONS wrapper docs (#8444)
* document java wrapper * [getsentry/action-github-commit] Auto commit * Update src/platform-includes/crons/setup/java.mdx Co-authored-by: Shana Matthews <[email protected]> * extract monitor config into var --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Shana Matthews <[email protected]>
1 parent 9397ea2 commit 2a26f8c

File tree

1 file changed

+54
-0
lines changed
  • src/platform-includes/crons/setup

1 file changed

+54
-0
lines changed

src/platform-includes/crons/setup/java.mdx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,60 @@ If you are using [Quartz](http://www.quartz-scheduler.org/), please see <Platfor
44

55
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).
66

7+
### Wrapper
8+
9+
The Sentry Java SDK offers a helper that takes care of wrapping your code and sending a check-in at the start and one at the end. It checks for exceptions and sets the status of the check-in accordingly.
10+
11+
```java
12+
import io.sentry.util.CheckInUtils;
13+
14+
String result = CheckInUtils.withCheckIn("<monitor-slug>", () -> {
15+
// Execute your scheduled task here...
16+
return "computed result";
17+
});
18+
```
19+
20+
```kotlin
21+
import io.sentry.util.CheckInUtils
22+
23+
CheckInUtils.withCheckIn("<monitor-slug>") {
24+
// Execute your scheduled task here...
25+
}
26+
```
27+
28+
You may also send a `MonitorConfig` with a `MontiorSchedule` so the monitor is created or updated (upsert) automatically.
29+
30+
```java
31+
import io.sentry.MonitorConfig;
32+
import io.sentry.MonitorSchedule;
33+
import io.sentry.MonitorScheduleUnit;
34+
import io.sentry.util.CheckInUtils;
35+
36+
MonitorConfig monitorConfig = new MonitorConfig(MonitorSchedule.interval(3, MonitorScheduleUnit.MINUTE));
37+
38+
String result = CheckInUtils.withCheckIn("<monitor-slug>", monitorConfig, () -> {
39+
// Execute your scheduled task here...
40+
return "computed result";
41+
});
42+
```
43+
44+
```kotlin
45+
import io.sentry.MonitorConfig
46+
import io.sentry.MonitorSchedule
47+
import io.sentry.MonitorScheduleUnit
48+
import io.sentry.util.CheckInUtils
49+
50+
val monitorConfig = MonitorConfig(MonitorSchedule.interval(3, MonitorScheduleUnit.MINUTE))
51+
52+
CheckInUtils.withCheckIn("<monitor-slug>", monitorConfig) {
53+
// Execute your scheduled task here...
54+
}
55+
```
56+
57+
### Manually sending check-ins
58+
59+
It is also possible to manually send check-ins.
60+
761
```java
862
import io.sentry.CheckIn;
963
import io.sentry.CheckInStatus;

0 commit comments

Comments
 (0)