Skip to content

Commit 92a43e5

Browse files
committed
Add support for failure_issue_threshold & recovery_threshold
1 parent a2b3932 commit 92a43e5

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require": {
2626
"php": "^7.2 | ^8.0",
2727
"illuminate/support": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0",
28-
"sentry/sentry": "^4.3",
28+
"sentry/sentry": "^4.4",
2929
"symfony/psr-http-message-bridge": "^1.0 | ^2.0 | ^6.0 | ^7.0",
3030
"nyholm/psr7": "^1.0"
3131
},

src/Sentry/Laravel/Features/ConsoleIntegration.php

+54-9
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,24 @@ public function onBoot(Cache $cache): void
4242
{
4343
$this->cache = $cache;
4444

45-
$startCheckIn = function (?string $slug, SchedulingEvent $scheduled, ?int $checkInMargin, ?int $maxRuntime, bool $updateMonitorConfig) {
46-
$this->startCheckIn($slug, $scheduled, $checkInMargin, $maxRuntime, $updateMonitorConfig);
45+
$startCheckIn = function (
46+
?string $slug,
47+
SchedulingEvent $scheduled,
48+
?int $checkInMargin,
49+
?int $maxRuntime,
50+
bool $updateMonitorConfig,
51+
?int $failureIssueThreshold,
52+
?int $recoveryThreshold,
53+
) {
54+
$this->startCheckIn(
55+
$slug,
56+
$scheduled,
57+
$checkInMargin,
58+
$maxRuntime,
59+
$updateMonitorConfig,
60+
$failureIssueThreshold,
61+
$recoveryThreshold
62+
);
4763
};
4864
$finishCheckIn = function (?string $slug, SchedulingEvent $scheduled, CheckInStatus $status) {
4965
$this->finishCheckIn($slug, $scheduled, $status);
@@ -53,17 +69,35 @@ public function onBoot(Cache $cache): void
5369
?string $monitorSlug = null,
5470
?int $checkInMargin = null,
5571
?int $maxRuntime = null,
56-
bool $updateMonitorConfig = true
72+
bool $updateMonitorConfig = true,
73+
?int $failureIssueThreshold = null,
74+
?int $recoveryThreshold = null
5775
) use ($startCheckIn, $finishCheckIn) {
5876
/** @var SchedulingEvent $this */
5977
if ($monitorSlug === null && $this->command === null) {
6078
throw new RuntimeException('The command string is null, please set a slug manually for this scheduled command using the `sentryMonitor(\'your-monitor-slug\')` macro.');
6179
}
6280

6381
return $this
64-
->before(function () use ($startCheckIn, $monitorSlug, $checkInMargin, $maxRuntime, $updateMonitorConfig) {
82+
->before(function () use (
83+
$startCheckIn,
84+
$monitorSlug,
85+
$checkInMargin,
86+
$maxRuntime,
87+
$updateMonitorConfig,
88+
$failureIssueThreshold,
89+
$recoveryThreshold
90+
) {
6591
/** @var SchedulingEvent $this */
66-
$startCheckIn($monitorSlug, $this, $checkInMargin, $maxRuntime, $updateMonitorConfig);
92+
$startCheckIn(
93+
$monitorSlug,
94+
$this,
95+
$checkInMargin,
96+
$maxRuntime,
97+
$updateMonitorConfig,
98+
$failureIssueThreshold,
99+
$recoveryThreshold
100+
);
67101
})
68102
->onSuccess(function () use ($finishCheckIn, $monitorSlug) {
69103
/** @var SchedulingEvent $this */
@@ -83,14 +117,23 @@ public function onBootInactive(): void
83117
?string $monitorSlug = null,
84118
?int $checkInMargin = null,
85119
?int $maxRuntime = null,
86-
bool $updateMonitorConfig = true
120+
bool $updateMonitorConfig = true,
121+
?int $failureIssueThreshold = null,
122+
?int $recoveryThreshold = null
87123
) {
88124
return $this;
89125
});
90126
}
91127

92-
private function startCheckIn(?string $slug, SchedulingEvent $scheduled, ?int $checkInMargin, ?int $maxRuntime, bool $updateMonitorConfig): void
93-
{
128+
private function startCheckIn(
129+
?string $slug,
130+
SchedulingEvent $scheduled,
131+
?int $checkInMargin,
132+
?int $maxRuntime,
133+
bool $updateMonitorConfig,
134+
?int $failureIssueThreshold,
135+
?int $recoveryThreshold
136+
): void {
94137
$checkInSlug = $slug ?? $this->makeSlugForScheduled($scheduled);
95138

96139
$checkIn = $this->createCheckIn($checkInSlug, CheckInStatus::inProgress());
@@ -106,7 +149,9 @@ private function startCheckIn(?string $slug, SchedulingEvent $scheduled, ?int $c
106149
MonitorSchedule::crontab($scheduled->getExpression()),
107150
$checkInMargin,
108151
$maxRuntime,
109-
$timezone
152+
$timezone,
153+
$failureIssueThreshold,
154+
$recoveryThreshold
110155
));
111156
}
112157

0 commit comments

Comments
 (0)