Merge pull request #23015 from nextcloud/bugfix/noid/warn-on-slow-dashboard-widgets
Log slow dashboard widgets
This commit is contained in:
commit
0e2f316ece
|
@ -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(),
|
||||
|
|
|
@ -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