Skip to content

Commit 5d03709

Browse files
committed
Don’t trace missing routes
1 parent 657b785 commit 5d03709

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

config/sentry.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
// Indicates if the tracing integrations supplied by Sentry should be loaded
4747
'default_integrations' => true,
48+
49+
// Indicates that requests without a matching route should be traced
50+
'missing_routes' => false,
4851
],
4952

5053
// @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii

src/Sentry/Laravel/Tracing/Middleware.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public function handle(Request $request, Closure $next)
6363
public function terminate(Request $request, $response): void
6464
{
6565
if ($this->transaction !== null && app()->bound(HubInterface::class)) {
66+
// We stop here if a route has not been matched unless we are configured to trace missing routes
67+
if (config('sentry.tracing.missing_routes', false) === false && $request->route() === null) {
68+
return;
69+
}
70+
6671
if ($this->appSpan !== null) {
6772
$this->appSpan->finish();
6873
}

0 commit comments

Comments
 (0)