Skip to content

Commit

Permalink
HTM-1227: allow monitoring of triggered jobs through Sentry (#990)
Browse files Browse the repository at this point in the history
  • Loading branch information
mprins authored Oct 14, 2024
1 parent 85e9cce commit eb34790
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ SPDX-License-Identifier: MIT
<artifactId>sentry-jdbc</artifactId>
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-quartz</artifactId>
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package org.tailormap.api.configuration;

import io.sentry.quartz.SentryJobListener;
import jakarta.annotation.PostConstruct;
import java.lang.invoke.MethodHandles;
import org.quartz.SchedulerException;
Expand All @@ -29,6 +30,10 @@ public SchedulerConfiguration(@Autowired SchedulerFactoryBean schedulerFactoryBe

@PostConstruct
public void addListeners() throws SchedulerException {
schedulerFactoryBean
.getScheduler()
.getListenerManager()
.addJobListener(new SentryJobListener());
if (logger.isDebugEnabled()) {
// Add debug logging listeners to the scheduler
schedulerFactoryBean
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/tailormap/api/scheduling/TaskCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
package org.tailormap.api.scheduling;

import static io.sentry.quartz.SentryJobListener.SENTRY_SLUG_KEY;

import java.lang.invoke.MethodHandles;
import java.util.UUID;
import org.quartz.CronScheduleBuilder;
Expand Down Expand Up @@ -62,6 +64,7 @@ public String createTask(
.withIdentity(jobDetail.getKey().getName(), jobDetail.getKey().getGroup())
.startAt(DateBuilder.futureDate(30, DateBuilder.IntervalUnit.SECOND))
.withPriority(jobData.getPriority())
.usingJobData(SENTRY_SLUG_KEY, "monitor_slug_cron_trigger_" + jobData.get("type"))
.withSchedule(
CronScheduleBuilder.cronSchedule(cronExpression)
.withMisfireHandlingInstructionFireAndProceed())
Expand Down

0 comments on commit eb34790

Please sign in to comment.