]> source.dussan.org Git - nextcloud-server.git/commitdiff
Log an error if a dashboard widget loads longer than 1 second
authorJoas Schilling <coding@schilljs.com>
Wed, 23 Sep 2020 10:14:01 +0000 (12:14 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 23 Sep 2020 10:14:01 +0000 (12:14 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Dashboard/Manager.php

index bc57326dff008d7912eff5da12820a506877e3e7..94b80a3b4a452a3d469459d64722853662f60c49 100644 (file)
@@ -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(),