From: Joas Schilling Date: Wed, 23 Sep 2020 10:14:31 +0000 (+0200) Subject: Log a warning if a "lazy" initial state loads longer than 1 second X-Git-Tag: v21.0.0beta1~529^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F23015%2Fhead;p=nextcloud-server.git Log a warning if a "lazy" initial state loads longer than 1 second Signed-off-by: Joas Schilling --- diff --git a/lib/private/InitialStateService.php b/lib/private/InitialStateService.php index 55ce9c41726..c74eb683bd9 100644 --- a/lib/private/InitialStateService.php +++ b/lib/private/InitialStateService.php @@ -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 = [];