Skip to content

Commit 6ece63f

Browse files
authored
[laravel] Version specific Cron guides (#12822)
1 parent e69d645 commit 6ece63f

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

platform-includes/crons/setup/php.laravel.mdx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
Use the Laravel SDK to monitor and notify you if your [scheduled task](https://laravel.com/docs/10.x/scheduling) is missed (or doesn't start when expected), if it fails due to a problem in the runtime (such as an error), or if it fails by exceeding its maximum runtime.
44

5-
To set up, add the `sentryMonitor()` macro to the scheduled tasks defined in your `app/Console/Kernel.php` file as shown below. (Please note, this will create a Cron monitor that will count against your quota.)
5+
To set up, add the `sentryMonitor()` macro to the scheduled tasks defined in your application as shown below. (Please note, this will create a Cron monitor that will count against your quota.)
66

7-
```php {filename:app/Console/Kernel.php}
7+
```php {tabTitle:Laravel 12.x & 11.x} {filename:routes/console.php}
8+
Schedule::command(SendEmailsCommand::class)
9+
->everyHour()
10+
->sentryMonitor(); // add this line
11+
```
12+
13+
```php {tabTitle:Laravel 10.x & 9.x & 8.x} {filename:app/Console/Kernel.php}
814
protected function schedule(Schedule $schedule)
915
{
1016
$schedule->command('emails:send')
@@ -21,7 +27,27 @@ For the best results, we recommend using Laravel's [`cron`](https://laravel.com/
2127
By default, the Laravel SDK will infer various parameters of your scheduled task.
2228
For greater control, we expose some optional parameters on the `sentryMonitor()` macro.
2329

24-
```php {filename:app/Console/Kernel.php}
30+
```php {tabTitle:Laravel 12.x & 11.x} {filename:routes/console.php}
31+
Schedule::command(SendEmailsCommand::class)
32+
->everyHour()
33+
->sentryMonitor(
34+
// Specify the slug of the job monitor in case of duplicate commands or if the monitor was created in the UI.
35+
monitorSlug: null,
36+
// Number of minutes before a check-in is considered missed.
37+
checkInMargin: 5,
38+
// Number of minutes before an in-progress check-in is marked timed out.
39+
maxRuntime: 15,
40+
// Create a new issue when this many consecutive missed or error check-ins are processed.
41+
failureIssueThreshold: 1,
42+
// Resolve the issue when this many consecutive healthy check-ins are processed.
43+
recoveryThreshold: 1,
44+
// In case you want to configure the job monitor exclusively in the UI, you can turn off sending the monitor config with the check-in.
45+
// Passing a monitor-slug is required in this case.
46+
updateMonitorConfig: false,
47+
)
48+
```
49+
50+
```php {tabTitle:Laravel 10.x & 9.x & 8.x} {filename:app/Console/Kernel.php}
2551
protected function schedule(Schedule $schedule)
2652
{
2753
$schedule->command('emails:send')

0 commit comments

Comments
 (0)