Skip to content

ref(core): Add MonitorConfigUtils to convert schedules to monitor configs - #6217

Open
wedamija wants to merge 6 commits into
mainfrom
danf/monitor-config-utils
Open

wedamija wants to merge 6 commits into
mainfrom
danf/monitor-config-utils

Conversation

@wedamija

@wedamija wedamija commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

📜 Description

Adds an internal helper, MonitorConfigUtils, that turns a job's schedule (a cron expression or a fixed interval, plus its time zone) into the MonitorConfig Sentry uses to create and update cron monitors.

It only returns a config when Sentry would read the schedule the same way the scheduler runs it. Cron dialects differ from the crontab format Sentry uses (seconds fields, day-of-week numbering, how day-of-month and day-of-week combine, older Spring parser rules), so schedules that can't be represented exactly get no config rather than a wrong one. A wrong schedule would cause false "missed check-in" alerts.

💡 Motivation and Context

Check-ins sent without a monitor config are dropped when the monitor doesn't exist yet, so users have to create every monitor by hand. Sending the config from code lets monitors be created and kept in sync automatically. This helper is the shared piece that the Spring (#6215) and Quartz (#6216) integrations use to do that.

💚 How did you test it?

Unit tests in MonitorConfigUtilsTest. Also compared the next fire times of 200k random cron expressions per scheduler (Spring 6.2, 5.3, 5.2 and Quartz 2.3) against Sentry's own cron parser: no mismatches for converted expressions.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.
  • I updated the wizard 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

#6215 and #6216 build on this.

#skip-changelog

…figs

Framework-free conversion of a 6 field cron expression, fixed rate or
fixed delay into a MonitorConfig, plus period parsing, so the Spring and
Quartz integrations can share it.
@sentry

sentry Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.59.0 (1) release

⚙️ sentry-android Build Distribution Settings

Return no config when day of month and day of week are both set, for
cron syntax Sentry rejects, and for zones that are not IANA region IDs.
Whole-hour fixed offsets map to Etc/GMT zones. Intervals use hours or
days when they divide evenly.
Move the Spring day-of-week rewrite and the JVM default zone rule into
core so the three Spring modules share them.
Spring and Quartz run 10-10/2 only at 10, cronsim steps to the field max.
Spring before 5.3 steps day of month */n from 0 and can run at midnight
when both day fields are set; read its crons that way. Spring 5.3 runs
#5 in months without a fifth weekday, so return null for it. A fixed
delay drifts from any interval, so it gets no config.
@wedamija
wedamija marked this pull request as ready for review October 5, 2026 22:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 780c605. Configure here.

Comment thread sentry/src/main/java/io/sentry/util/MonitorConfigUtils.java
SUN-SUN was rewritten to 0-7, which crontab reads as every day.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant