fix(sentry): use withScope for SSH retry event tracking (#8363)
This commit is contained in:
commit
5d54bc1c96
1 changed files with 0 additions and 41 deletions
|
|
@ -95,9 +95,6 @@ protected function executeWithSshRetry(callable $callback, array $context = [],
|
||||||
if ($this->isRetryableSshError($lastErrorMessage) && $attempt < $maxRetries - 1) {
|
if ($this->isRetryableSshError($lastErrorMessage) && $attempt < $maxRetries - 1) {
|
||||||
$delay = $this->calculateRetryDelay($attempt);
|
$delay = $this->calculateRetryDelay($attempt);
|
||||||
|
|
||||||
// Track SSH retry event in Sentry
|
|
||||||
$this->trackSshRetryEvent($attempt + 1, $maxRetries, $delay, $lastErrorMessage, $context);
|
|
||||||
|
|
||||||
// Add deployment log if available (for ExecuteRemoteCommand trait)
|
// Add deployment log if available (for ExecuteRemoteCommand trait)
|
||||||
if (isset($this->application_deployment_queue) && method_exists($this, 'addRetryLogEntry')) {
|
if (isset($this->application_deployment_queue) && method_exists($this, 'addRetryLogEntry')) {
|
||||||
$this->addRetryLogEntry($attempt + 1, $maxRetries, $delay, $lastErrorMessage);
|
$this->addRetryLogEntry($attempt + 1, $maxRetries, $delay, $lastErrorMessage);
|
||||||
|
|
@ -133,42 +130,4 @@ protected function executeWithSshRetry(callable $callback, array $context = [],
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Track SSH retry event in Sentry
|
|
||||||
*/
|
|
||||||
protected function trackSshRetryEvent(int $attempt, int $maxRetries, int $delay, string $errorMessage, array $context = []): void
|
|
||||||
{
|
|
||||||
// Only track in production/cloud instances
|
|
||||||
if (isDev() || ! config('constants.sentry.sentry_dsn')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
app('sentry')->captureMessage(
|
|
||||||
'SSH connection retry triggered',
|
|
||||||
\Sentry\Severity::warning(),
|
|
||||||
[
|
|
||||||
'extra' => [
|
|
||||||
'attempt' => $attempt,
|
|
||||||
'max_retries' => $maxRetries,
|
|
||||||
'delay_seconds' => $delay,
|
|
||||||
'error_message' => $errorMessage,
|
|
||||||
'context' => $context,
|
|
||||||
'retryable_error' => true,
|
|
||||||
],
|
|
||||||
'tags' => [
|
|
||||||
'component' => 'ssh_retry',
|
|
||||||
'error_type' => 'connection_retry',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
// Don't let Sentry tracking errors break the SSH retry flow
|
|
||||||
Log::warning('Failed to track SSH retry event in Sentry', [
|
|
||||||
'error' => $e->getMessage(),
|
|
||||||
'original_attempt' => $attempt,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue