Skip to content

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

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

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

Conversation

@wedamija

@wedamija wedamija commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

📜 Description

Adds io.sentry.util.MonitorConfigUtils (@ApiStatus.Internal), which turns a schedule into a MonitorConfig:

  • fromSchedule(cron, zone, intervalMillis): a 6-field cron with a fixed seconds field becomes a 5-field crontab (macros expanded, ? becomes *); a whole-minute interval becomes an interval in minutes, hours or days. Anything else returns null.
  • No config rather than a wrong one: a cron with both day-of-month and day-of-week set (crontab ORs them), syntax Sentry's cron parser rejects (W, L-3, wrap-around ranges, ...), a stepped single-value range like 10-10/2 (Spring and Quartz run only at 10, Sentry steps to the field max), or a zone that isn't an IANA ID returns null. Whole-hour offsets like GMT+2 become Etc/GMT-2.
  • parsePeriodMillis(value, defaultUnit): a plain number or a simple duration like 5m.
  • fromSpringScheduled(cron, zone, fixedRateMillis, fixedDelayMillis, legacyCronParser): the same for resolved Spring @Scheduled values, using the JVM default zone for a cron without zone. Spring 5.3+: rewrites day-of-week names and */n so crontab reads them like Spring; #5 returns null (Spring 5.3 also runs it in months without a fifth weekday). Before 5.3 (CronSequenceGenerator): day-of-month */n becomes n-31/n; both day fields set returns null (it sometimes runs at midnight). A fixed delay returns null, as runs drift from any interval.

💡 Motivation and Context

Shared by #6215 (Spring) and #6216 (Quartz).

💚 How did you test it?

MonitorConfigUtilsTest. Fuzzed 200k random crons each against Spring 6.2.11, 5.3.39, 5.2.25 and Quartz 2.3.2 (next 120 fire times vs. cronsim, the parser Sentry uses): no mismatches for converted crons.

📝 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.

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