44import io .sentry .CheckInStatus ;
55import io .sentry .DateUtils ;
66import io .sentry .IHub ;
7+ import io .sentry .MonitorConfig ;
78import io .sentry .Sentry ;
89import io .sentry .protocol .SentryId ;
910import java .util .List ;
@@ -18,21 +19,29 @@ public final class CheckInUtils {
1819 /**
1920 * Helper method to send monitor check-ins for a {@link Callable}
2021 *
22+ * @param monitorSlug - the slug of the monitor
23+ * @param monitorConfig - configuration of the monitor, can be used for upserting schedule
2124 * @param callable - the {@link Callable} to be called
2225 * @return the return value of the {@link Callable}
2326 * @param <U> - the result type of the {@link Callable}
2427 */
2528 public static <U > U withCheckIn (
26- final @ NotNull String monitorSlug , final @ NotNull Callable <U > callable ) throws Exception {
29+ final @ NotNull String monitorSlug ,
30+ final @ Nullable MonitorConfig monitorConfig ,
31+ final @ NotNull Callable <U > callable )
32+ throws Exception {
2733 final @ NotNull IHub hub = Sentry .getCurrentHub ();
2834 final long startTime = System .currentTimeMillis ();
2935 boolean didError = false ;
3036
3137 hub .pushScope ();
3238 TracingUtils .startNewTrace (hub );
3339
34- @ Nullable
35- SentryId checkInId = hub .captureCheckIn (new CheckIn (monitorSlug , CheckInStatus .IN_PROGRESS ));
40+ CheckIn inProgressCheckIn = new CheckIn (monitorSlug , CheckInStatus .IN_PROGRESS );
41+ if (monitorConfig != null ) {
42+ inProgressCheckIn .setMonitorConfig (monitorConfig );
43+ }
44+ @ Nullable SentryId checkInId = hub .captureCheckIn (inProgressCheckIn );
3645 try {
3746 return callable .call ();
3847 } catch (Throwable t ) {
@@ -47,6 +56,19 @@ public static <U> U withCheckIn(
4756 }
4857 }
4958
59+ /**
60+ * Helper method to send monitor check-ins for a {@link Callable}
61+ *
62+ * @param monitorSlug - the slug of the monitor
63+ * @param callable - the {@link Callable} to be called
64+ * @return the return value of the {@link Callable}
65+ * @param <U> - the result type of the {@link Callable}
66+ */
67+ public static <U > U withCheckIn (
68+ final @ NotNull String monitorSlug , final @ NotNull Callable <U > callable ) throws Exception {
69+ return withCheckIn (monitorSlug , null , callable );
70+ }
71+
5072 /** Checks if a check-in for a monitor (CRON) has been ignored. */
5173 @ ApiStatus .Internal
5274 public static boolean isIgnored (
0 commit comments