From 1197b712b450477ae600dba8d15c4f41d18948e8 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Tue, 27 Feb 2024 23:44:11 +0100 Subject: [PATCH 1/2] ref(backend): Sett HTTP client timeout and HTTP client spans --- src/Http/Client.php | 12 +++++++----- src/Http/SlackClient.php | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Http/Client.php b/src/Http/Client.php index f2072f7b..7a4d660a 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -38,11 +38,13 @@ protected function _sendRequest(RequestInterface $request, array $options): Resp $span = $parentSpan->startChild($context); } - $response = parent::_sendRequest($request, $options); - - if ($span !== null) { - $span->setHttpStatus($response->getStatusCode()); - $span->finish(); + try { + $response = parent::_sendRequest($request, $options); + } finally { + if ($span !== null) { + $span->setHttpStatus($response->getStatusCode()); + $span->finish(); + } } return $response; diff --git a/src/Http/SlackClient.php b/src/Http/SlackClient.php index 46f09a85..c53bbdfd 100644 --- a/src/Http/SlackClient.php +++ b/src/Http/SlackClient.php @@ -24,6 +24,7 @@ public function __construct() 'headers' => [ 'Authorization' => 'Bearer ' . env('SLACK_BOT_USER_OAUTH_TOKEN'), ], + 'timeout' => 5, ]); } From c2ab690f325a098c8d6d2431ff33e46bc6db1faf Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Tue, 27 Feb 2024 23:51:04 +0100 Subject: [PATCH 2/2] CS --- src/Http/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Client.php b/src/Http/Client.php index 7a4d660a..714696a8 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -39,7 +39,7 @@ protected function _sendRequest(RequestInterface $request, array $options): Resp } try { - $response = parent::_sendRequest($request, $options); + $response = parent::_sendRequest($request, $options); } finally { if ($span !== null) { $span->setHttpStatus($response->getStatusCode());