From 92a43e53f15e3be1d3beae5216a804282dcb8e24 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Tue, 23 Jan 2024 11:51:11 +0100 Subject: [PATCH] Add support for `failure_issue_threshold` & `recovery_threshold` --- composer.json | 2 +- .../Laravel/Features/ConsoleIntegration.php | 63 ++++++++++++++++--- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index d02e445a..501b8cc8 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": "^7.2 | ^8.0", "illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0", - "sentry/sentry": "^4.3", + "sentry/sentry": "^4.4", "symfony/psr-http-message-bridge": "^1.0 | ^2.0 | ^6.0 | ^7.0", "nyholm/psr7": "^1.0" }, diff --git a/src/Sentry/Laravel/Features/ConsoleIntegration.php b/src/Sentry/Laravel/Features/ConsoleIntegration.php index b44f5f94..79dfb770 100644 --- a/src/Sentry/Laravel/Features/ConsoleIntegration.php +++ b/src/Sentry/Laravel/Features/ConsoleIntegration.php @@ -42,8 +42,24 @@ public function onBoot(Cache $cache): void { $this->cache = $cache; - $startCheckIn = function (?string $slug, SchedulingEvent $scheduled, ?int $checkInMargin, ?int $maxRuntime, bool $updateMonitorConfig) { - $this->startCheckIn($slug, $scheduled, $checkInMargin, $maxRuntime, $updateMonitorConfig); + $startCheckIn = function ( + ?string $slug, + SchedulingEvent $scheduled, + ?int $checkInMargin, + ?int $maxRuntime, + bool $updateMonitorConfig, + ?int $failureIssueThreshold, + ?int $recoveryThreshold, + ) { + $this->startCheckIn( + $slug, + $scheduled, + $checkInMargin, + $maxRuntime, + $updateMonitorConfig, + $failureIssueThreshold, + $recoveryThreshold + ); }; $finishCheckIn = function (?string $slug, SchedulingEvent $scheduled, CheckInStatus $status) { $this->finishCheckIn($slug, $scheduled, $status); @@ -53,7 +69,9 @@ public function onBoot(Cache $cache): void ?string $monitorSlug = null, ?int $checkInMargin = null, ?int $maxRuntime = null, - bool $updateMonitorConfig = true + bool $updateMonitorConfig = true, + ?int $failureIssueThreshold = null, + ?int $recoveryThreshold = null ) use ($startCheckIn, $finishCheckIn) { /** @var SchedulingEvent $this */ if ($monitorSlug === null && $this->command === null) { @@ -61,9 +79,25 @@ public function onBoot(Cache $cache): void } return $this - ->before(function () use ($startCheckIn, $monitorSlug, $checkInMargin, $maxRuntime, $updateMonitorConfig) { + ->before(function () use ( + $startCheckIn, + $monitorSlug, + $checkInMargin, + $maxRuntime, + $updateMonitorConfig, + $failureIssueThreshold, + $recoveryThreshold + ) { /** @var SchedulingEvent $this */ - $startCheckIn($monitorSlug, $this, $checkInMargin, $maxRuntime, $updateMonitorConfig); + $startCheckIn( + $monitorSlug, + $this, + $checkInMargin, + $maxRuntime, + $updateMonitorConfig, + $failureIssueThreshold, + $recoveryThreshold + ); }) ->onSuccess(function () use ($finishCheckIn, $monitorSlug) { /** @var SchedulingEvent $this */ @@ -83,14 +117,23 @@ public function onBootInactive(): void ?string $monitorSlug = null, ?int $checkInMargin = null, ?int $maxRuntime = null, - bool $updateMonitorConfig = true + bool $updateMonitorConfig = true, + ?int $failureIssueThreshold = null, + ?int $recoveryThreshold = null ) { return $this; }); } - private function startCheckIn(?string $slug, SchedulingEvent $scheduled, ?int $checkInMargin, ?int $maxRuntime, bool $updateMonitorConfig): void - { + private function startCheckIn( + ?string $slug, + SchedulingEvent $scheduled, + ?int $checkInMargin, + ?int $maxRuntime, + bool $updateMonitorConfig, + ?int $failureIssueThreshold, + ?int $recoveryThreshold + ): void { $checkInSlug = $slug ?? $this->makeSlugForScheduled($scheduled); $checkIn = $this->createCheckIn($checkInSlug, CheckInStatus::inProgress()); @@ -106,7 +149,9 @@ private function startCheckIn(?string $slug, SchedulingEvent $scheduled, ?int $c MonitorSchedule::crontab($scheduled->getExpression()), $checkInMargin, $maxRuntime, - $timezone + $timezone, + $failureIssueThreshold, + $recoveryThreshold )); }