fusonic / sentry-cron
Automatic Sentry Cron check-ins with Symfony Scheduler
Installs: 431
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/fusonic/sentry-cron
Requires
- php: >=8.2
- dragonmantank/cron-expression: ^3.4
- sentry/sentry: ^4.14
- symfony/messenger: ^6.4 || ^7.3 || ^8.0
- symfony/scheduler: ^6.4 || ^7.3 || ^8.0
- symfony/string: ^6.4 || ^7.3 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.91
- infection/infection: ^0.31
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^12.4
- rector/rector: ^2.2
- tomasvotruba/type-coverage: ^2.0
This package is auto-updated.
Last update: 2025-12-04 12:25:11 UTC
README
About
Automatically register scheduled events from Symfony Scheduler in Sentry Cron. Only cron expressions are supported.
Install
Use composer to install the library from packagist.
composer require fusonic/sentry-cron
Configuration
Fusonic\SentryCron\SentrySchedulerEventSubscriber: arguments: $enabled: true
Usage
Any regular event that is triggered with a cron expression can be used.
Event Configuration
By default, the Sentry defaults are used for monitor configurations. Per event, you can configure an attribute to use your own configuration:
use Fusonic\SentryCron\SentryMonitorConfig; #[SentryMonitorConfig(checkinMargin: 30, maxRuntime: 30, failureIssueThreshold: 5, recoveryThreshold: 5)] class SomeEvent { // ... }
Async Events
If you have an unpredictable longer-running scheduled task, you can manually check in by implementing AsyncCheckInScheduleEventInterface.
The scheduled event:
use Fusonic\SentryCron\SentryMonitorConfig; use Fusonic\SentryCron\AsyncCheckInScheduleEventInterface; use \Fusonic\SentryCron\AsyncCheckInScheduleEventTrait; class SomeEvent implements AsyncCheckInScheduleEventInterface { use AsyncCheckInScheduleEventTrait; // ... }
The manual check in:
class SomeEventHandler { private const BATCH_SIZE = 100; public function __invoke(SomeEvent $event): void { $offset = 0; // e.g.: some slow database processing $entitiesToProcess = // ... $nextEvent = new SomeEvent(offset: $offset + self::BATCH_SIZE); if (count($entitiesToProcess) === 0) { $nextEvent->markAsLast(); } $this->eventBus->dispatch($nextEvent); } }