Skip to content

Commit

Permalink
fix: Status code not populated on transaction if response did not inh…
Browse files Browse the repository at this point in the history
…erit from the Laravel Response class (#573)

Co-authored-by: Alex Bouma <alex@bouma.me>
  • Loading branch information
ydwis40 and stayallive committed Sep 29, 2022
1 parent afe3567 commit fc510b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix status code not populated on transaction if response did not inherit from `Illuminate\Http\Response` like `Illuminate\Http\JsonResponse` (#573)

## 2.13.0

- Only catch `BindingResolutionException` when trying to get the PSR-7 request object from the container
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Laravel/Tracing/Middleware.php
Expand Up @@ -4,14 +4,14 @@

use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Route;
use Sentry\Laravel\Integration;
use Sentry\SentrySdk;
use Sentry\State\HubInterface;
use Sentry\Tracing\Span;
use Sentry\Tracing\SpanContext;
use Sentry\Tracing\TransactionContext;
use Symfony\Component\HttpFoundation\Response;

class Middleware
{
Expand Down Expand Up @@ -56,8 +56,8 @@ public function handle($request, Closure $next)
/**
* Handle the application termination.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Response $response
* @param \Illuminate\Http\Request $request
* @param \Symfony\Component\HttpFoundation\Response $response
*
* @return void
*/
Expand Down Expand Up @@ -208,7 +208,7 @@ private function hydrateRequestData(Request $request): void

private function hydrateResponseData(Response $response): void
{
$this->transaction->setHttpStatus($response->status());
$this->transaction->setHttpStatus($response->getStatusCode());
}

private function updateTransactionNameIfDefault(?string $name): void
Expand Down

0 comments on commit fc510b4

Please sign in to comment.