Skip to content

Commit

Permalink
Merge pull request #98 from olivernybroe/fix-load-time
Browse files Browse the repository at this point in the history
Fix load time not being difference between start and now
  • Loading branch information
JustSteveKing authored Oct 10, 2024
2 parents 931f721 + 42b4403 commit d3969a7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Middlewares/TreblleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ public function terminate(Request $request, JsonResponse|Response|SymfonyRespons
data: $this->factory->make(
request: $request,
response: $response,
loadTime: $_SERVER['REQUEST_TIME_FLOAT']
?? (defined('LARAVEL_START') ? LARAVEL_START : null)
?? microtime(true),
loadTime: microtime(true) - $this->startTime(),
),
projectId: self::$project ?? (string) config('treblle.project_id'),
);
}

private function startTime(): float
{
return $_SERVER['REQUEST_TIME_FLOAT']
?? (defined('LARAVEL_START') ? LARAVEL_START : null)
?? microtime(true);
}
}

0 comments on commit d3969a7

Please sign in to comment.