From 74f4dbe9de9dd720c3392c4e5d49cc63a6f6e1d1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Sep 2020 12:14:01 +0200 Subject: Log an error if a dashboard widget loads longer than 1 second Signed-off-by: Joas Schilling --- lib/private/Dashboard/Manager.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/private') 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(), -- cgit v1.2.3