Skip to content

Commit

Permalink
fix(potal|backend): Add missing response status to HTTP client spans
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Jul 10, 2024
1 parent 9e2e24b commit d762635
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions potal/internal/potalhttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d762635

Please sign in to comment.