Skip to content

Commit

Permalink
Move root path handling to getRouteUri function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mads Jon Nielsen authored and firecow committed May 4, 2023
1 parent 4f4664a commit 839e303
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public function handle(RequestReceived $event): void
$manager = $event->app->make(OctaneApmManager::class);

$routeUri = $this->getRouteUri($event);
if ($routeUri === "/") {
$manager->beginTransaction($event->request->method() . ' /', 'request');
} else {
$manager->beginTransaction($event->request->method() . ' /' . $routeUri, 'request');
}
$manager->beginTransaction($event->request->method() . ' /' . $routeUri, 'request');
}

/**
Expand All @@ -42,7 +38,8 @@ private function getRouteUri(RequestReceived $event): string
$router = $event->sandbox->make('router');

try {
return $router->getRoutes()->match($event->request)->uri();
$routeUri = $router->getRoutes()->match($event->request)->uri();
return $routeUri === "/" ? "" : $routeUri;
} catch (Throwable $throwable) {
// If the route does not exist, then simply return the path
return $event->request->path();
Expand Down

0 comments on commit 839e303

Please sign in to comment.