]> source.dussan.org Git - nextcloud-server.git/commitdiff
instrumentation for app booting 36641/head
authorRobin Appelman <robin@icewind.nl>
Thu, 9 Feb 2023 15:05:59 +0000 (16:05 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 9 Feb 2023 16:41:43 +0000 (17:41 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/AppFramework/Bootstrap/Coordinator.php
lib/private/legacy/OC_App.php

index 6f2e8b91a887d537e1034e902d3c21716e54f96e..f41b734a25bcad5e70c9821434829f1c0b15ab23 100644 (file)
@@ -104,8 +104,8 @@ class Coordinator {
                }
                $apps = [];
                foreach ($appIds as $appId) {
-                       $this->eventLogger->start("bootstrap:register_app:$appId", '');
-                       $this->eventLogger->start("bootstrap:register_app:$appId:autoloader", '');
+                       $this->eventLogger->start("bootstrap:register_app:$appId", "Register $appId");
+                       $this->eventLogger->start("bootstrap:register_app:$appId:autoloader", "Setup autoloader for $appId");
                        /*
                         * First, we have to enable the app's autoloader
                         *
@@ -120,14 +120,14 @@ class Coordinator {
                        $this->eventLogger->end("bootstrap:register_app:$appId:autoloader");
 
                        /*
-                        * Next we check if there is an application class and it implements
+                        * Next we check if there is an application class, and it implements
                         * the \OCP\AppFramework\Bootstrap\IBootstrap interface
                         */
                        $appNameSpace = App::buildAppNamespace($appId);
                        $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
                        try {
                                if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) {
-                                       $this->eventLogger->start("bootstrap:register_app:$appId:application", '');
+                                       $this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId");
                                        try {
                                                /** @var IBootstrap|App $application */
                                                $apps[$appId] = $application = $this->serverContainer->query($applicationClassName);
@@ -138,7 +138,7 @@ class Coordinator {
                                        }
                                        $this->eventLogger->end("bootstrap:register_app:$appId:application");
 
-                                       $this->eventLogger->start("bootstrap:register_app:$appId:register", '');
+                                       $this->eventLogger->start("bootstrap:register_app:$appId:register", "`Application::register` for $appId");
                                        $application->register($this->registrationContext->for($appId));
                                        $this->eventLogger->end("bootstrap:register_app:$appId:register");
                                }
@@ -153,7 +153,7 @@ class Coordinator {
                        $this->eventLogger->end("bootstrap:register_app:$appId");
                }
 
-               $this->eventLogger->start('bootstrap:register_apps:apply', '');
+               $this->eventLogger->start('bootstrap:register_apps:apply', 'Apply all the registered service by apps');
                /**
                 * Now that all register methods have been called, we can delegate the registrations
                 * to the actual services
@@ -190,7 +190,7 @@ class Coordinator {
                 * the instance was already created for register, but any other
                 * (legacy) code will now do their magic via the constructor.
                 */
-               $this->eventLogger->start('bootstrap:boot_app_' . $appId, '');
+               $this->eventLogger->start('bootstrap:boot_app:' . $appId, "Call `Application::boot` for $appId");
                try {
                        /** @var App $application */
                        $application = $this->serverContainer->query($applicationClassName);
@@ -208,7 +208,7 @@ class Coordinator {
                                'exception' => $e,
                        ]);
                }
-               $this->eventLogger->end('bootstrap:boot_app_' . $appId);
+               $this->eventLogger->end('bootstrap:boot_app:' . $appId);
        }
 
        public function isBootable(string $appId) {
index 2a420fd71adff03e72c6ac6b5edd4333061394dd..7f51d81d21bbaa5ff418e7f08f82762504de5549 100644 (file)
@@ -167,6 +167,8 @@ class OC_App {
                if ($appPath === false) {
                        return;
                }
+               $eventLogger = \OC::$server->get(\OCP\Diagnostics\IEventLogger::class);
+               $eventLogger->start("bootstrap:load_app:$app", "Load $app");
 
                // in case someone calls loadApp() directly
                self::registerAutoloading($app, $appPath);
@@ -177,12 +179,12 @@ class OC_App {
 
                $hasAppPhpFile = is_file($appPath . '/appinfo/app.php');
 
-               \OC::$server->getEventLogger()->start('bootstrap:load_app_' . $app, 'Load app: ' . $app);
                if ($isBootable && $hasAppPhpFile) {
                        \OC::$server->getLogger()->error('/appinfo/app.php is not loaded when \OCP\AppFramework\Bootstrap\IBootstrap on the application class is used. Migrate everything from app.php to the Application class.', [
                                'app' => $app,
                        ]);
                } elseif ($hasAppPhpFile) {
+                       $eventLogger->start("bootstrap:load_app:$app:app.php", "Load legacy app.php app $app");
                        \OC::$server->getLogger()->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
                                'app' => $app,
                        ]);
@@ -205,11 +207,12 @@ class OC_App {
                                        ]);
                                }
                        }
+                       $eventLogger->end("bootstrap:load_app:$app:app.php");
                }
-               \OC::$server->getEventLogger()->end('bootstrap:load_app_' . $app);
 
                $coordinator->bootApp($app);
 
+               $eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
                $info = self::getAppInfo($app);
                if (!empty($info['activity']['filters'])) {
                        foreach ($info['activity']['filters'] as $filter) {
@@ -264,6 +267,10 @@ class OC_App {
                                }
                        }
                }
+
+               $eventLogger->end("bootstrap:load_app:$app:info");
+
+               $eventLogger->end("bootstrap:load_app:$app");
        }
 
        /**