Log a warning if a "lazy" initial state loads longer than 1 second
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
87f8e1e366
commit
5475bb4083
|
@ -72,7 +72,17 @@ class InitialStateService implements IInitialStateService {
|
|||
private function invokeLazyStateCallbacks(): void {
|
||||
foreach ($this->lazyStates as $app => $lazyStates) {
|
||||
foreach ($lazyStates as $key => $lazyState) {
|
||||
$startTime = microtime(true);
|
||||
$this->provideInitialState($app, $key, $lazyState());
|
||||
$endTime = microtime(true);
|
||||
$duration = $endTime - $startTime;
|
||||
if ($duration > 1) {
|
||||
$this->logger->warning('Lazy initial state provider for {key} took {duration} seconds.', [
|
||||
'app' => $app,
|
||||
'key' => $key,
|
||||
'duration' => round($duration, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->lazyStates = [];
|
||||
|
|
Loading…
Reference in New Issue