diff --git a/sentry-quartz/api/sentry-quartz.api b/sentry-quartz/api/sentry-quartz.api index 34a71295845..ff32280dc5b 100644 --- a/sentry-quartz/api/sentry-quartz.api +++ b/sentry-quartz/api/sentry-quartz.api @@ -5,8 +5,9 @@ public final class io/sentry/quartz/BuildConfig { public final class io/sentry/quartz/SentryJobListener : org/quartz/JobListener { public static final field SENTRY_CHECK_IN_ID_KEY Ljava/lang/String; - public static final field SENTRY_CHECK_IN_SLUG_KEY Ljava/lang/String; + public static final field SENTRY_SLUG_KEY Ljava/lang/String; public fun ()V + public fun (Lio/sentry/IHub;)V public fun getName ()Ljava/lang/String; public fun jobExecutionVetoed (Lorg/quartz/JobExecutionContext;)V public fun jobToBeExecuted (Lorg/quartz/JobExecutionContext;)V diff --git a/sentry-quartz/src/main/java/io/sentry/quartz/SentryJobListener.java b/sentry-quartz/src/main/java/io/sentry/quartz/SentryJobListener.java index 96f5014988f..84e499fca2e 100644 --- a/sentry-quartz/src/main/java/io/sentry/quartz/SentryJobListener.java +++ b/sentry-quartz/src/main/java/io/sentry/quartz/SentryJobListener.java @@ -3,37 +3,34 @@ import io.sentry.BuildConfig; import io.sentry.CheckIn; import io.sentry.CheckInStatus; -import io.sentry.MonitorConfig; -import io.sentry.MonitorSchedule; -import io.sentry.MonitorScheduleUnit; -import io.sentry.Sentry; +import io.sentry.HubAdapter; +import io.sentry.IHub; import io.sentry.SentryIntegrationPackageStorage; import io.sentry.SentryLevel; import io.sentry.protocol.SentryId; -import java.util.List; -import java.util.TimeZone; +import io.sentry.util.Objects; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.quartz.CalendarIntervalTrigger; -import org.quartz.CronTrigger; -import org.quartz.DateBuilder; -import org.quartz.Job; -import org.quartz.JobDetail; +import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; -import org.quartz.JobKey; import org.quartz.JobListener; -import org.quartz.SimpleTrigger; -import org.quartz.Trigger; @ApiStatus.Experimental public final class SentryJobListener implements JobListener { public static final String SENTRY_CHECK_IN_ID_KEY = "sentry-checkin-id"; - public static final String SENTRY_CHECK_IN_SLUG_KEY = "sentry-checkin-slug"; + public static final String SENTRY_SLUG_KEY = "sentry-slug"; + + private final @NotNull IHub hub; public SentryJobListener() { + this(HubAdapter.getInstance()); + } + + public SentryJobListener(final @NotNull IHub hub) { + this.hub = Objects.requireNonNull(hub, "hub is required"); SentryIntegrationPackageStorage.getInstance().addIntegration("Quartz"); SentryIntegrationPackageStorage.getInstance() .addPackage("maven:io.sentry:sentry-quartz", BuildConfig.VERSION_NAME); @@ -45,133 +42,31 @@ public String getName() { } @Override - public void jobToBeExecuted(JobExecutionContext context) { + public void jobToBeExecuted(final @NotNull JobExecutionContext context) { try { - final @NotNull String slug = getSlug(context.getJobDetail()); - final @NotNull CheckIn checkIn = new CheckIn(slug, CheckInStatus.IN_PROGRESS); - - final @Nullable MonitorConfig monitorConfig = extractMonitorConfig(context); - if (monitorConfig != null) { - checkIn.setMonitorConfig(monitorConfig); + final @Nullable String maybeSlug = getSlug(context); + if (maybeSlug == null) { + return; } - - final @NotNull SentryId checkInId = Sentry.captureCheckIn(checkIn); + final @NotNull String slug = maybeSlug; + final @NotNull CheckIn checkIn = new CheckIn(slug, CheckInStatus.IN_PROGRESS); + final @NotNull SentryId checkInId = hub.captureCheckIn(checkIn); context.put(SENTRY_CHECK_IN_ID_KEY, checkInId); - context.put(SENTRY_CHECK_IN_SLUG_KEY, slug); + context.put(SENTRY_SLUG_KEY, slug); } catch (Throwable t) { - Sentry.getCurrentHub() - .getOptions() + hub.getOptions() .getLogger() .log(SentryLevel.ERROR, "Unable to capture check-in in jobToBeExecuted.", t); } } - private @NotNull String getSlug(final @Nullable JobDetail jobDetail) { - if (jobDetail == null) { - return "fallback"; - } - final @NotNull StringBuilder slugBuilder = new StringBuilder(); - - final @Nullable JobKey key = jobDetail.getKey(); - if (key != null) { - slugBuilder.append(key.getName()); - slugBuilder.append("__"); - } - - final @Nullable Class jobClass = jobDetail.getJobClass(); - if (jobClass != null) { - slugBuilder.append(jobClass.getCanonicalName()); - } - - return slugBuilder.toString(); - } - - private @Nullable MonitorConfig extractMonitorConfig(final @NotNull JobExecutionContext context) { - @Nullable MonitorSchedule schedule = null; - @Nullable String cronExpression = null; - @Nullable TimeZone timeZone = TimeZone.getDefault(); - @Nullable Integer repeatInterval = null; - @Nullable MonitorScheduleUnit timeUnit = null; - - try { - List triggersOfJob = - context.getScheduler().getTriggersOfJob(context.getTrigger().getJobKey()); - for (Trigger trigger : triggersOfJob) { - if (trigger instanceof CronTrigger) { - final CronTrigger cronTrigger = (CronTrigger) trigger; - cronExpression = cronTrigger.getCronExpression(); - timeZone = cronTrigger.getTimeZone(); - } else if (trigger instanceof SimpleTrigger) { - final SimpleTrigger simpleTrigger = (SimpleTrigger) trigger; - long tmpRepeatInterval = simpleTrigger.getRepeatInterval(); - repeatInterval = millisToMinutes(Double.valueOf(tmpRepeatInterval)); - timeUnit = MonitorScheduleUnit.MINUTE; - } else if (trigger instanceof CalendarIntervalTrigger) { - final CalendarIntervalTrigger calendarIntervalTrigger = (CalendarIntervalTrigger) trigger; - DateBuilder.IntervalUnit repeatIntervalUnit = - calendarIntervalTrigger.getRepeatIntervalUnit(); - int tmpRepeatInterval = calendarIntervalTrigger.getRepeatInterval(); - if (DateBuilder.IntervalUnit.SECOND.equals(repeatIntervalUnit)) { - repeatInterval = secondsToMinutes(Double.valueOf(tmpRepeatInterval)); - timeUnit = MonitorScheduleUnit.MINUTE; - } else if (DateBuilder.IntervalUnit.MILLISECOND.equals(repeatIntervalUnit)) { - repeatInterval = millisToMinutes(Double.valueOf(tmpRepeatInterval)); - timeUnit = MonitorScheduleUnit.MINUTE; - } else { - repeatInterval = tmpRepeatInterval; - timeUnit = convertUnit(repeatIntervalUnit); - } - } - } - } catch (Throwable t) { - Sentry.getCurrentHub() - .getOptions() - .getLogger() - .log(SentryLevel.ERROR, "Unable to extract monitor config for check-in.", t); - } - if (cronExpression != null) { - schedule = MonitorSchedule.crontab(cronExpression); - } else if (repeatInterval != null && timeUnit != null) { - schedule = MonitorSchedule.interval(repeatInterval.intValue(), timeUnit); - } - - if (schedule != null) { - final @Nullable MonitorConfig monitorConfig = new MonitorConfig(schedule); - if (timeZone != null) { - monitorConfig.setTimezone(timeZone.getID()); + private @Nullable String getSlug(final @NotNull JobExecutionContext context) { + final @Nullable JobDataMap jobDataMap = context.getMergedJobDataMap(); + if (jobDataMap != null) { + final @Nullable Object o = jobDataMap.get(SENTRY_SLUG_KEY); + if (o != null) { + return o.toString(); } - return monitorConfig; - } else { - return null; - } - } - - private @Nullable Integer millisToMinutes(final @NotNull Double milis) { - return Double.valueOf((milis / 1000.0) / 60.0).intValue(); - } - - private @Nullable Integer secondsToMinutes(final @NotNull Double seconds) { - return Double.valueOf(seconds / 60.0).intValue(); - } - - private @Nullable MonitorScheduleUnit convertUnit( - final @Nullable DateBuilder.IntervalUnit intervalUnit) { - if (intervalUnit == null) { - return null; - } - - if (DateBuilder.IntervalUnit.MINUTE.equals(intervalUnit)) { - return MonitorScheduleUnit.MINUTE; - } else if (DateBuilder.IntervalUnit.HOUR.equals(intervalUnit)) { - return MonitorScheduleUnit.HOUR; - } else if (DateBuilder.IntervalUnit.DAY.equals(intervalUnit)) { - return MonitorScheduleUnit.DAY; - } else if (DateBuilder.IntervalUnit.WEEK.equals(intervalUnit)) { - return MonitorScheduleUnit.WEEK; - } else if (DateBuilder.IntervalUnit.MONTH.equals(intervalUnit)) { - return MonitorScheduleUnit.MONTH; - } else if (DateBuilder.IntervalUnit.YEAR.equals(intervalUnit)) { - return MonitorScheduleUnit.YEAR; } return null; @@ -186,7 +81,7 @@ public void jobExecutionVetoed(JobExecutionContext context) { public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { try { final @Nullable Object checkInIdObjectFromContext = context.get(SENTRY_CHECK_IN_ID_KEY); - final @Nullable Object slugObjectFromContext = context.get(SENTRY_CHECK_IN_SLUG_KEY); + final @Nullable Object slugObjectFromContext = context.get(SENTRY_SLUG_KEY); final @NotNull SentryId checkInId = checkInIdObjectFromContext == null ? new SentryId() @@ -196,11 +91,10 @@ public void jobWasExecuted(JobExecutionContext context, JobExecutionException jo if (slug != null) { final boolean isFailed = jobException != null; final @NotNull CheckInStatus status = isFailed ? CheckInStatus.ERROR : CheckInStatus.OK; - Sentry.captureCheckIn(new CheckIn(checkInId, slug, status)); + hub.captureCheckIn(new CheckIn(checkInId, slug, status)); } } catch (Throwable t) { - Sentry.getCurrentHub() - .getOptions() + hub.getOptions() .getLogger() .log(SentryLevel.ERROR, "Unable to capture check-in in jobWasExecuted.", t); } diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/java/io/sentry/samples/spring/boot/jakarta/SentryDemoApplication.java b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/java/io/sentry/samples/spring/boot/jakarta/SentryDemoApplication.java index d9e4a7cdb5e..74b1ac3f71b 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/java/io/sentry/samples/spring/boot/jakarta/SentryDemoApplication.java +++ b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/java/io/sentry/samples/spring/boot/jakarta/SentryDemoApplication.java @@ -1,6 +1,9 @@ package io.sentry.samples.spring.boot.jakarta; +import static io.sentry.quartz.SentryJobListener.SENTRY_SLUG_KEY; + import io.sentry.samples.spring.boot.jakarta.quartz.SampleJob; +import java.util.Collections; import org.quartz.JobDetail; import org.quartz.SimpleTrigger; import org.springframework.boot.SpringApplication; @@ -8,6 +11,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.quartz.CronTriggerFactoryBean; import org.springframework.scheduling.quartz.JobDetailFactoryBean; import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; import org.springframework.web.client.RestTemplate; @@ -33,10 +37,10 @@ WebClient webClient(WebClient.Builder builder) { @Bean public JobDetailFactoryBean jobDetail() { JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean(); - jobDetailFactory.setName("hello there 123"); jobDetailFactory.setJobClass(SampleJob.class); - jobDetailFactory.setDescription("Invoke Sample Job service..."); jobDetailFactory.setDurability(true); + jobDetailFactory.setJobDataAsMap( + Collections.singletonMap(SENTRY_SLUG_KEY, "monitor_slug_job_detail")); return jobDetailFactory; } @@ -44,16 +48,18 @@ public JobDetailFactoryBean jobDetail() { public SimpleTriggerFactoryBean trigger(JobDetail job) { SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean(); trigger.setJobDetail(job); - trigger.setRepeatInterval(2 * 60 * 1000); + trigger.setRepeatInterval(2 * 60 * 1000); // every two minutes trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY); + trigger.setJobDataAsMap( + Collections.singletonMap(SENTRY_SLUG_KEY, "monitor_slug_simple_trigger")); return trigger; } - // @Bean - // public CronTriggerFactoryBean trigger(JobDetail job) { - // CronTriggerFactoryBean trigger = new CronTriggerFactoryBean(); - // trigger.setJobDetail(job); - // trigger.setCronExpression("0 /5 * ? * *"); - // return trigger; - // } + @Bean + public CronTriggerFactoryBean cronTrigger(JobDetail job) { + CronTriggerFactoryBean trigger = new CronTriggerFactoryBean(); + trigger.setJobDetail(job); + trigger.setCronExpression("0 0/5 * ? * *"); // every five minutes + return trigger; + } } diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties index ba90224f37c..d06f7e0878b 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot-jakarta/src/main/resources/application.properties @@ -10,7 +10,6 @@ sentry.logging.minimum-breadcrumb-level=debug # Performance configuration sentry.traces-sample-rate=1.0 sentry.enable-tracing=true -sentry.enable-automatic-checkins=true sentry.ignored-checkins=ignored_monitor_slug_1,ignored_monitor_slug_2 sentry.debug=true in-app-includes="io.sentry.samples" diff --git a/sentry-samples/sentry-samples-spring-boot/src/main/java/io/sentry/samples/spring/boot/SentryDemoApplication.java b/sentry-samples/sentry-samples-spring-boot/src/main/java/io/sentry/samples/spring/boot/SentryDemoApplication.java index ff02e3d01c2..b4f46260997 100644 --- a/sentry-samples/sentry-samples-spring-boot/src/main/java/io/sentry/samples/spring/boot/SentryDemoApplication.java +++ b/sentry-samples/sentry-samples-spring-boot/src/main/java/io/sentry/samples/spring/boot/SentryDemoApplication.java @@ -1,6 +1,9 @@ package io.sentry.samples.spring.boot; +import static io.sentry.quartz.SentryJobListener.SENTRY_SLUG_KEY; + import io.sentry.samples.spring.boot.quartz.SampleJob; +import java.util.Collections; import org.quartz.JobDetail; import org.quartz.SimpleTrigger; import org.springframework.boot.SpringApplication; @@ -8,6 +11,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.quartz.CronTriggerFactoryBean; import org.springframework.scheduling.quartz.JobDetailFactoryBean; import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean; import org.springframework.web.client.RestTemplate; @@ -33,27 +37,29 @@ WebClient webClient(WebClient.Builder builder) { @Bean public JobDetailFactoryBean jobDetail() { JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean(); - jobDetailFactory.setName("hello_spring_boot_2"); jobDetailFactory.setJobClass(SampleJob.class); - jobDetailFactory.setDescription("Invoke Sample Job service..."); jobDetailFactory.setDurability(true); + jobDetailFactory.setJobDataAsMap( + Collections.singletonMap(SENTRY_SLUG_KEY, "monitor_slug_job_detail")); return jobDetailFactory; } - // @Bean - // public CronTriggerFactoryBean trigger(JobDetail job) { - // CronTriggerFactoryBean trigger = new CronTriggerFactoryBean(); - // trigger.setJobDetail(job); - // trigger.setCronExpression("0 * * ? * *"); - // return trigger; - // } - @Bean public SimpleTriggerFactoryBean trigger(JobDetail job) { SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean(); trigger.setJobDetail(job); - trigger.setRepeatInterval(2 * 60 * 1000); + trigger.setRepeatInterval(2 * 60 * 1000); // every two minutes trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY); + trigger.setJobDataAsMap( + Collections.singletonMap(SENTRY_SLUG_KEY, "monitor_slug_simple_trigger")); + return trigger; + } + + @Bean + public CronTriggerFactoryBean cronTrigger(JobDetail job) { + CronTriggerFactoryBean trigger = new CronTriggerFactoryBean(); + trigger.setJobDetail(job); + trigger.setCronExpression("0 0/5 * ? * *"); // every five minutes return trigger; } } diff --git a/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties b/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties index ef8e5484b94..31989d2dfea 100644 --- a/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties +++ b/sentry-samples/sentry-samples-spring-boot/src/main/resources/application.properties @@ -10,7 +10,6 @@ sentry.logging.minimum-breadcrumb-level=debug # Performance configuration sentry.traces-sample-rate=1.0 sentry.enable-tracing=true -sentry.enable-automatic-checkins=true sentry.ignored-checkins=ignored_monitor_slug_1,ignored_monitor_slug_2 sentry.debug=true in-app-includes="io.sentry.samples" diff --git a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt index 015b22cfac3..d4c90e0b058 100644 --- a/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt @@ -162,7 +162,6 @@ class SentryAutoConfigurationTest { "sentry.trace-propagation-targets=localhost,^(http|https)://api\\..*\$", "sentry.enabled=false", "sentry.send-modules=false", - "sentry.enable-automatic-checkins=true", "sentry.ignored-checkins=slug1,slugB" ).run { val options = it.getBean(SentryProperties::class.java) @@ -194,7 +193,6 @@ class SentryAutoConfigurationTest { assertThat(options.tracePropagationTargets).containsOnly("localhost", "^(http|https)://api\\..*\$") assertThat(options.isEnabled).isEqualTo(false) assertThat(options.isSendModules).isEqualTo(false) - assertThat(options.isEnableAutomaticCheckIns).isEqualTo(true) assertThat(options.ignoredCheckIns).containsOnly("slug1", "slugB") } } @@ -733,7 +731,7 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, creates quartz config`() { + fun `creates quartz config`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") .run { assertThat(it).hasSingleBean(SchedulerFactoryBeanCustomizer::class.java) @@ -741,7 +739,7 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, does not create quartz config if quartz lib missing`() { + fun `does not create quartz config if quartz lib missing`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") .withClassLoader(FilteredClassLoader(QuartzScheduler::class.java)) .run { @@ -750,7 +748,7 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, does not create quartz config if spring-quartz lib missing`() { + fun `does not create quartz config if spring-quartz lib missing`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") .withClassLoader(FilteredClassLoader(SchedulerFactoryBean::class.java)) .run { @@ -759,7 +757,7 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, does not create quartz config if sentry-quartz lib missing`() { + fun `does not create quartz config if sentry-quartz lib missing`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") .withClassLoader(FilteredClassLoader(SentryJobListener::class.java)) .run { @@ -767,22 +765,6 @@ class SentryAutoConfigurationTest { } } - @Test - fun `when auto checkins is disabled, does not create quartz config`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=false") - .run { - assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) - } - } - - @Test - fun `when auto checkins option is skipped, does not create quartz config`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") - .run { - assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) - } - } - @Configuration(proxyBeanMethods = false) open class CustomOptionsConfigurationConfiguration { diff --git a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt index 0336b2f6d25..44f280e6cbe 100644 --- a/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt @@ -162,7 +162,6 @@ class SentryAutoConfigurationTest { "sentry.trace-propagation-targets=localhost,^(http|https)://api\\..*\$", "sentry.enabled=false", "sentry.send-modules=false", - "sentry.enable-automatic-checkins=true", "sentry.ignored-checkins=slug1,slugB" ).run { val options = it.getBean(SentryProperties::class.java) @@ -194,7 +193,6 @@ class SentryAutoConfigurationTest { assertThat(options.tracePropagationTargets).containsOnly("localhost", "^(http|https)://api\\..*\$") assertThat(options.isEnabled).isEqualTo(false) assertThat(options.isSendModules).isEqualTo(false) - assertThat(options.isEnableAutomaticCheckIns).isEqualTo(true) assertThat(options.ignoredCheckIns).containsOnly("slug1", "slugB") } } @@ -733,16 +731,16 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, creates quartz config`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") + fun `creates quartz config`() { + contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .run { assertThat(it).hasSingleBean(SchedulerFactoryBeanCustomizer::class.java) } } @Test - fun `when auto checkins is enabled, does not create quartz config if quartz lib missing`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") + fun `does not create quartz config if quartz lib missing`() { + contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .withClassLoader(FilteredClassLoader(QuartzScheduler::class.java)) .run { assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) @@ -750,8 +748,8 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, does not create quartz config if spring-quartz lib missing`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") + fun `does not create quartz config if spring-quartz lib missing`() { + contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .withClassLoader(FilteredClassLoader(SchedulerFactoryBean::class.java)) .run { assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) @@ -759,25 +757,9 @@ class SentryAutoConfigurationTest { } @Test - fun `when auto checkins is enabled, does not create quartz config if sentry-quartz lib missing`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=true") - .withClassLoader(FilteredClassLoader(SentryJobListener::class.java)) - .run { - assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) - } - } - - @Test - fun `when auto checkins is disabled, does not create quartz config`() { - contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj", "sentry.enable-automatic-checkins=false") - .run { - assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) - } - } - - @Test - fun `when auto checkins option is skipped, does not create quartz config`() { + fun `does not create quartz config if sentry-quartz lib missing`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") + .withClassLoader(FilteredClassLoader(SentryJobListener::class.java)) .run { assertThat(it).doesNotHaveBean(SchedulerFactoryBeanCustomizer::class.java) } diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index 40efd78815b..b629b7993eb 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -336,14 +336,12 @@ public final class io/sentry/ExternalOptions { public fun getTracePropagationTargets ()Ljava/util/List; public fun getTracesSampleRate ()Ljava/lang/Double; public fun getTracingOrigins ()Ljava/util/List; - public fun isEnableAutomaticCheckIns ()Ljava/lang/Boolean; public fun isEnablePrettySerializationOutput ()Ljava/lang/Boolean; public fun isEnabled ()Ljava/lang/Boolean; public fun isSendModules ()Ljava/lang/Boolean; public fun setDebug (Ljava/lang/Boolean;)V public fun setDist (Ljava/lang/String;)V public fun setDsn (Ljava/lang/String;)V - public fun setEnableAutomaticCheckIns (Ljava/lang/Boolean;)V public fun setEnableDeduplication (Ljava/lang/Boolean;)V public fun setEnablePrettySerializationOutput (Ljava/lang/Boolean;)V public fun setEnableTracing (Ljava/lang/Boolean;)V @@ -1984,7 +1982,6 @@ public class io/sentry/SentryOptions { public fun isAttachThreads ()Z public fun isDebug ()Z public fun isEnableAutoSessionTracking ()Z - public fun isEnableAutomaticCheckIns ()Z public fun isEnableDeduplication ()Z public fun isEnableExternalConfiguration ()Z public fun isEnableNdk ()Z @@ -2021,7 +2018,6 @@ public class io/sentry/SentryOptions { public fun setDistinctId (Ljava/lang/String;)V public fun setDsn (Ljava/lang/String;)V public fun setEnableAutoSessionTracking (Z)V - public fun setEnableAutomaticCheckIns (Z)V public fun setEnableDeduplication (Z)V public fun setEnableExternalConfiguration (Z)V public fun setEnableNdk (Z)V diff --git a/sentry/src/main/java/io/sentry/ExternalOptions.java b/sentry/src/main/java/io/sentry/ExternalOptions.java index 604a001da99..adb25811e0e 100644 --- a/sentry/src/main/java/io/sentry/ExternalOptions.java +++ b/sentry/src/main/java/io/sentry/ExternalOptions.java @@ -46,7 +46,6 @@ public final class ExternalOptions { private @Nullable Boolean enabled; private @Nullable Boolean enablePrettySerializationOutput; - private @Nullable Boolean enableAutomaticCheckIns; private @Nullable List ignoredCheckIns; private @Nullable Boolean sendModules; @@ -130,9 +129,6 @@ public final class ExternalOptions { options.setSendModules(propertiesProvider.getBooleanProperty("send-modules")); - options.setEnableAutomaticCheckIns( - propertiesProvider.getBooleanProperty("enable-automatic-checkins")); - options.setIgnoredCheckIns(propertiesProvider.getList("ignored-checkins")); for (final String ignoredExceptionType : @@ -393,16 +389,6 @@ public void setSendModules(final @Nullable Boolean sendModules) { this.sendModules = sendModules; } - @ApiStatus.Experimental - public @Nullable Boolean isEnableAutomaticCheckIns() { - return enableAutomaticCheckIns; - } - - @ApiStatus.Experimental - public void setEnableAutomaticCheckIns(final @Nullable Boolean enableAutomaticCheckIns) { - this.enableAutomaticCheckIns = enableAutomaticCheckIns; - } - @ApiStatus.Experimental public void setIgnoredCheckIns(final @Nullable List ignoredCheckIns) { this.ignoredCheckIns = ignoredCheckIns; diff --git a/sentry/src/main/java/io/sentry/SentryOptions.java b/sentry/src/main/java/io/sentry/SentryOptions.java index d14b3150a2d..7b33347cbcb 100644 --- a/sentry/src/main/java/io/sentry/SentryOptions.java +++ b/sentry/src/main/java/io/sentry/SentryOptions.java @@ -443,9 +443,6 @@ public class SentryOptions { /** Whether to send modules containing information about versions. */ private boolean sendModules = true; - /** Whether to automatically send check-ins for monitors (CRONS). */ - @ApiStatus.Experimental private boolean enableAutomaticCheckIns = false; - /** Contains a list of monitor slugs for which check-ins should not be sent. */ @ApiStatus.Experimental private @Nullable List ignoredCheckIns = null; @@ -2147,16 +2144,6 @@ public boolean isSendModules() { return sendModules; } - /** - * Whether to send check-ins for monitors (CRONS) automatically. - * - * @return true if check-ins should be sent automatically. - */ - @ApiStatus.Experimental - public boolean isEnableAutomaticCheckIns() { - return enableAutomaticCheckIns; - } - /** * Whether to format serialized data, e.g. events logged to console in debug mode * @@ -2175,16 +2162,6 @@ public void setSendModules(boolean sendModules) { this.sendModules = sendModules; } - /** - * Whether to send check-ins for monitors (CRONS) automatically. - * - * @param enableAutomaticCheckIns true if check-ins should be sent automatically. - */ - @ApiStatus.Experimental - public void setEnableAutomaticCheckIns(boolean enableAutomaticCheckIns) { - this.enableAutomaticCheckIns = enableAutomaticCheckIns; - } - @ApiStatus.Experimental public void setIgnoredCheckIns(final @Nullable List ignoredCheckIns) { if (ignoredCheckIns == null) { @@ -2454,10 +2431,6 @@ public void merge(final @NotNull ExternalOptions options) { if (options.isSendModules() != null) { setSendModules(options.isSendModules()); } - - if (options.isEnableAutomaticCheckIns() != null) { - setEnableAutomaticCheckIns(options.isEnableAutomaticCheckIns()); - } if (options.getIgnoredCheckIns() != null) { final List ignoredCheckIns = new ArrayList<>(options.getIgnoredCheckIns()); setIgnoredCheckIns(ignoredCheckIns); diff --git a/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt b/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt index fc95bed9e7c..929db8ad06c 100644 --- a/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt +++ b/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt @@ -261,13 +261,6 @@ class ExternalOptionsTest { } } - @Test - fun `creates options with enableAutomaticCheckIns set to true`() { - withPropertiesFile("enable-automatic-checkins=true") { options -> - assertTrue(options.isEnableAutomaticCheckIns == true) - } - } - @Test fun `creates options with ignoredCheckIns`() { withPropertiesFile("ignored-checkins=slugA,slug2") { options -> diff --git a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt index 2b13764916f..ce211c9414a 100644 --- a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt +++ b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt @@ -371,7 +371,6 @@ class SentryOptionsTest { externalOptions.isEnabled = false externalOptions.isEnablePrettySerializationOutput = false externalOptions.isSendModules = false - externalOptions.isEnableAutomaticCheckIns = true externalOptions.ignoredCheckIns = listOf("slug1", "slug-B") val options = SentryOptions() @@ -401,7 +400,6 @@ class SentryOptionsTest { assertFalse(options.isEnabled) assertFalse(options.isEnablePrettySerializationOutput) assertFalse(options.isSendModules) - assertTrue(options.isEnableAutomaticCheckIns) assertEquals(listOf("slug1", "slug-B"), options.ignoredCheckIns) }