diff --git a/platform-includes/crons/requirements/java.mdx b/platform-includes/crons/requirements/java.mdx index 510d0678eb16c..654d75f626cbc 100644 --- a/platform-includes/crons/requirements/java.mdx +++ b/platform-includes/crons/requirements/java.mdx @@ -6,5 +6,5 @@ - Send a monitor configuration from your code as shown below, and Sentry creates the monitor on the first check-in. You can also [create the monitor in Sentry](https://sentry.io/issues/alerts/new/crons/) instead. -- From Sentry Java SDK version `8.64.0`, `@SentryCheckIn(upsertMonitorConfig = true)` sends a monitor configuration based on the method's `@Scheduled` annotation, and Sentry creates the monitor on the first check-in. Without it, on older SDK versions, or for schedules that can't be converted, [create the monitor in Sentry](https://sentry.io/issues/alerts/new/crons/) first, because Sentry drops check-ins for a slug that has no monitor. +- From Sentry Java SDK version `8.64.0`, `sentry.monitor-scheduled-tasks=true` and `@SentryCheckIn(upsertMonitorConfig = true)` send a monitor configuration based on the method's `@Scheduled` annotation, and Sentry creates the monitor on the first check-in. Without either, on older SDK versions, or for schedules that can't be converted, [create the monitor in Sentry](https://sentry.io/issues/alerts/new/crons/) first, because Sentry drops check-ins for a slug that has no monitor. diff --git a/platform-includes/crons/setup/java.spring-boot.mdx b/platform-includes/crons/setup/java.spring-boot.mdx index b48a78d756b9d..6f966ecac4982 100644 --- a/platform-includes/crons/setup/java.spring-boot.mdx +++ b/platform-includes/crons/setup/java.spring-boot.mdx @@ -2,13 +2,31 @@ If you are using [Quartz](http://www.quartz-scheduler.org/), please see -The `@SentryCheckIn` annotation requires `org.aspectj:aspectjweaver` to be present as a dependency in your project. +The `@SentryCheckIn` annotation and `sentry.monitor-scheduled-tasks` require `org.aspectj:aspectjweaver` to be present as a dependency in your project. ## Check-Ins (Recommended) -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). To start sending check-ins simply add the `@SentryCheckIn("")` annotation to the method you want to send check-ins for. +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). + +### Monitor All `@Scheduled` Methods + +We recommend monitoring every `@Scheduled` method. From Sentry Java SDK version `8.64.0`, you can do this without adding `@SentryCheckIn` to each one: + +```properties {filename:application.properties} +sentry.monitor-scheduled-tasks=true +# Optional: methods to skip, as ClassName.methodName or a regular expression +sentry.exclude-scheduled-tasks=ReportJobs.sendDailyReport,Internal.* +``` + +Each method gets a monitor slug built from its class and method name, for example `report-jobs-send-daily-report` for `ReportJobs.sendDailyReport`. Nested classes include the outer class name (`Outer.Inner.method`), and slugs longer than 50 characters are shortened with a hash suffix. The schedule is always sent, as described in [Monitor Configuration From `@Scheduled`](#monitor-configuration-from-scheduled), so Sentry creates each monitor on its first check-in. Methods with schedules that can't be expressed in the Crons schedule format (for example, a `fixedDelay` job) aren't monitored. To monitor one, add `@SentryCheckIn` with a slug and create the monitor in Sentry first. + +Methods annotated with `@SentryCheckIn` keep their own slug and settings, including `upsertMonitorConfig`, and are checked in once per run. Methods on `final` classes, `final`, `private`, and `static` methods, and reactive or Kotlin `suspend` methods can't be monitored this way. + +### Monitor Specific Methods + +To send check-ins for specific methods, add the `@SentryCheckIn("")` annotation to the method you want to send check-ins for. ```java {tabTitle:Java (Spring Boot 3)} {mdExpandTabs} import io.sentry.spring.jakarta.checkin.SentryCheckIn;