Conversation
…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.
4 of 9 tasks
📲 Install BuildsAndroid
|
3 of 9 tasks
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Adds
io.sentry.util.MonitorConfigUtils(@ApiStatus.Internal), which turns a schedule into aMonitorConfig: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.W,L-3, wrap-around ranges, ...), a stepped single-value range like10-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 likeGMT+2becomeEtc/GMT-2.parsePeriodMillis(value, defaultUnit): a plain number or a simple duration like5m.fromSpringScheduled(cron, zone, fixedRateMillis, fixedDelayMillis, legacyCronParser): the same for resolved Spring@Scheduledvalues, using the JVM default zone for a cron withoutzone. Spring 5.3+: rewrites day-of-week names and*/nso crontab reads them like Spring;#5returns null (Spring 5.3 also runs it in months without a fifth weekday). Before 5.3 (CronSequenceGenerator): day-of-month*/nbecomesn-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
sendDefaultPIIis enabled.🔮 Next steps
#6215 and #6216 build on this.
#skip-changelog