diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-09-24 14:57:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 14:57:17 +0200 |
commit | 0e2f316ece9a0f5ec5db271f3a5c50a767c76030 (patch) | |
tree | 542dbbb0ecc8e95e07330df3da5b8b5e4327432f /lib/private | |
parent | acba3da7c877fbb470078489fe6346fbf157d317 (diff) | |
parent | b497067ead79d617a09d081f580b1cd930fcb771 (diff) | |
download | nextcloud-server-0e2f316ece9a0f5ec5db271f3a5c50a767c76030.tar.gz nextcloud-server-0e2f316ece9a0f5ec5db271f3a5c50a767c76030.zip |
Merge pull request #23015 from nextcloud/bugfix/noid/warn-on-slow-dashboard-widgets
Log slow dashboard widgets
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Dashboard/Manager.php | 9 | ||||
-rw-r--r-- | lib/private/InitialStateService.php | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/private/Dashboard/Manager.php b/lib/private/Dashboard/Manager.php index bc57326dff0..94b80a3b4a4 100644 --- a/lib/private/Dashboard/Manager.php +++ b/lib/private/Dashboard/Manager.php @@ -95,7 +95,16 @@ class Manager implements IManager { } try { + $startTime = microtime(true); $widget->load(); + $endTime = microtime(true); + $duration = $endTime - $startTime; + if ($duration > 1) { + \OC::$server->getLogger()->error('Dashboard widget {widget} took {duration} seconds to load.', [ + 'widget' => $widget->getId(), + 'duration' => round($duration, 2), + ]); + } } catch (Throwable $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'Error during dashboard widget loading: ' . $e->getMessage(), 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 = []; |