Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support check-ins for Quartz #2940

Merged
merged 19 commits into from
Sep 25, 2023
Merged

Conversation

adinauer
Copy link
Member

📜 Description

Add a JobListener for automatically reporting check-ins for scheduled Quartz jobs.

💡 Motivation and Context

Quartz support for #2875

💚 How did you test it?

Manually with samples

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- Support check-ins for Quartz ([#2940](https://github.com/getsentry/sentry-java/pull/2940))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by 🚫 dangerJS against 600a58c

@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 347.16 ms 384.06 ms 36.90 ms
Size 1.72 MiB 2.29 MiB 575.93 KiB

Previous results on branch: feat/crons-quartz

Startup times

Revision Plain With Sentry Diff
20bea77 333.96 ms 460.00 ms 126.04 ms
1cdfac5 375.94 ms 456.28 ms 80.35 ms

App size

Revision Plain With Sentry Diff
20bea77 1.72 MiB 2.29 MiB 575.93 KiB
1cdfac5 1.72 MiB 2.29 MiB 575.93 KiB

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch has no changes to coverable lines.

❗ Current head f4fb1dd differs from pull request most recent head 600a58c. Consider uploading reports for the commit 600a58c to get more accurate results

📢 Thoughts on this report? Let us know!.

@adinauer adinauer self-assigned this Sep 19, 2023
Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change the way we handle the monitor config, as described in the comment. Otherwise LGTM

@Nullable MonitorScheduleUnit timeUnit = null;

try {
List<? extends Trigger> triggersOfJob =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use context.getTrigger() instead?
Maybe we'd also have to add some part of the trigger to the monitor slug.
Because the we way it is now, if we have two or more triggers for the job it will always take the info of the last CronTrigger in the triggersOfJob list.

Small example (add to SentryDemoApplication in jakarta):

  @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);
    return jobDetailFactory;
  }

  @Bean
  public SimpleTriggerFactoryBean trigger(JobDetail job) {
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setRepeatInterval(10000);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    return trigger;
  }

    @Bean
    public CronTriggerFactoryBean trigger2(JobDetail job) {
      CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
      trigger.setJobDetail(job);
      trigger.setCronExpression("0/20 * * ? * *");
      return trigger;
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment there's no support for multiple triggers in Sentry. I opted for a more consistent approach by getting the list of triggers so we don't update the monitor config on every invocation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer send the schedule and also get the slug from the job data map. We'll document how to handle multiple triggers.

@adinauer adinauer changed the base branch from main to feat/crons-lib-support September 25, 2023 12:24
@adinauer adinauer changed the title Automatic CRON checkins for Quartz Support check-ins for Quartz Sep 25, 2023
@adinauer adinauer merged commit 41cf842 into feat/crons-lib-support Sep 25, 2023
12 of 14 checks passed
@adinauer adinauer deleted the feat/crons-quartz branch September 25, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants