Skip to content

fix: Status code not populated on transaction if response did not inherit from the Laravel Response class #573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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