Skip to content

feat(spring): Send monitor config from @Scheduled with @SentryCheckIn - #6215

Draft
wedamija wants to merge 15 commits into
danf/monitor-config-utilsfrom
danf/spring-checkin-scheduled-config
Draft

wedamija wants to merge 15 commits into
danf/monitor-config-utilsfrom
danf/spring-checkin-scheduled-config

Conversation

@wedamija

@wedamija wedamija commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Stacked on #6217 (core MonitorConfigUtils).

Reviewing: sentry-spring, sentry-spring-jakarta and sentry-spring-7 get the same change apart from packages, so review sentry-spring; the other two are copies.

📜 Description

With @SentryCheckIn(upsertMonitorConfig = true) (opt-in, default false), the advice reads the method's @Scheduled and sends a monitor config with the in-progress check-in, so Sentry creates or updates the monitor from code.

  • cron: converted by MonitorConfigUtils.fromSpringScheduled (ref(core): Add MonitorConfigUtils to convert schedules to monitor configs #6217) so crontab reads it like Spring. Spring before 5.3 parses crons differently, so the advice checks for CronExpression and picks the matching rules. The zone, or the JVM default zone, is sent as the timezone.
  • fixedRate (including fixedRateString, ISO-8601 durations and timeUnit): an interval when it's a whole number of minutes.
  • fixedDelay sends no config: the next run starts after the previous one ends, so it would raise false missed alerts.
  • Placeholders are resolved, and the config is derived once per method.
  • Heartbeats, multiple @Scheduled, and schedules that can't be converted send no config, as today.

Sentry merges the config into an existing monitor. Margins, max runtime and thresholds set in the UI are kept unless options.cron sets defaults for them, which are sent with every check-in.

💡 Motivation and Context

Without a config, check-ins for monitors that weren't created in Sentry are dropped. @Scheduled already has the schedule.

💚 How did you test it?

SentryCheckInAdviceTest in each Spring module. The conversion rules are tested in #6217.

📝 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

Docs: getsentry/sentry-docs#19780

Derive a monitor config from the method's @scheduled annotation and send
it with the in-progress check-in, so Sentry can create or update the
monitor from code. Cron expressions with a fixed seconds field and fixed
rates/delays in whole minutes are converted; other schedules send no
config. Opt out with @SentryCheckIn(upsertMonitorConfig = false).
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against ff1e1e2

@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

…figs

Framework-free conversion of a 6 field cron expression, fixed rate or
fixed delay into a MonitorConfig, so the Spring modules can share it.
Keep only the Spring-specific part in the three advices (finding
@scheduled, reading its attributes, resolving placeholders) and move the
conversion edge-case tests to core.
Add parsePeriodMillis for plain numbers and the 5m/30s style Spring 6.1
accepts, and make the cron macro map unmodifiable.
Spring runs a cron without zone in the JVM default time zone, so send
that instead of leaving it to UTC. Accept simple duration periods, log
unparseable ones at debug, and derive the config once per method.
@wedamija
wedamija changed the base branch from main to danf/monitor-config-utils October 2, 2026 19:54
Sending the monitor config changes existing behaviour, so it now needs
@SentryCheckIn(upsertMonitorConfig = true).
Spring starts '*' on Monday and numbers Sunday 7, so '*/2' and 'SUN/2'
meant different days in crontab. Day names become numbers. Cache the
config with computeIfAbsent.
Keep only the Spring glue in each module and move the conversion
rule tests to core.
Read crons the way CronSequenceGenerator does on Spring before 5.3.
Derive the monitor config before the job's try block and catch any
Throwable, so a failure there never skips the job. Fixed delays get 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