]> source.dussan.org Git - nextcloud-server.git/commitdiff
Log a warning if a "lazy" initial state loads longer than 1 second 23032/head
authorJoas Schilling <coding@schilljs.com>
Wed, 23 Sep 2020 10:14:31 +0000 (12:14 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 24 Sep 2020 13:00:19 +0000 (13:00 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/InitialStateService.php

index 55ce9c4172607e5248eb06f1353989c83489697c..c74eb683bd9655c3a6ca01fd26b0446d64b02ed2 100644 (file)
@@ -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 = [];