From 2cea19c80055ef7fc6cbc2be19547e07499c9e16 Mon Sep 17 00:00:00 2001 From: Michi Hoffmann Date: Wed, 10 Jul 2024 23:19:22 +0200 Subject: [PATCH] fix(potal|backend): Add missing response status to HTTP client spans (#196) --- potal/internal/potalhttp/client.go | 4 ++++ src/Http/Client.php | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/potal/internal/potalhttp/client.go b/potal/internal/potalhttp/client.go index f06f4aba..b82e0040 100644 --- a/potal/internal/potalhttp/client.go +++ b/potal/internal/potalhttp/client.go @@ -52,6 +52,10 @@ func SendRequest(ctx context.Context, e event.PotalEvent) error { } defer res.Body.Close() + span.Data = map[string]interface{}{ + "http.response.status_code": res.StatusCode, + } + switch res.StatusCode { case http.StatusOK: span.Status = sentry.SpanStatusOK diff --git a/src/Http/Client.php b/src/Http/Client.php index f2072f7b..e92fdae3 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -41,8 +41,12 @@ protected function _sendRequest(RequestInterface $request, array $options): Resp $response = parent::_sendRequest($request, $options); if ($span !== null) { - $span->setHttpStatus($response->getStatusCode()); - $span->finish(); + $span + ->setHttpStatus($response->getStatusCode()) + ->setData([ + 'http.response.status_code' => $response->getStatusCode(), + ]) + ->finish(); } return $response;