summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/base.php7
-rw-r--r--lib/private/AppFramework/Bootstrap/Coordinator.php10
-rw-r--r--lib/private/Diagnostics/EventLogger.php2
-rw-r--r--lib/private/legacy/OC_App.php5
-rw-r--r--tests/lib/AppFramework/Bootstrap/CoordinatorTest.php6
5 files changed, 27 insertions, 3 deletions
diff --git a/lib/base.php b/lib/base.php
index 3c10f7cb33a..3ce9d4d9c95 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -61,6 +61,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Group\Events\UserRemovedEvent;
use OCP\ILogger;
@@ -595,8 +596,13 @@ class OC {
// setup the basic server
self::$server = new \OC\Server(\OC::$WEBROOT, self::$config);
self::$server->boot();
+
$eventLogger = \OC::$server->getEventLogger();
$eventLogger->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd);
+ $eventLogger->start('request', 'Full request after autoloading');
+ register_shutdown_function(function () use ($eventLogger) {
+ $eventLogger->end('request');
+ });
$eventLogger->start('boot', 'Initialize');
// Override php.ini and log everything if we're troubleshooting
@@ -792,6 +798,7 @@ class OC {
}
}
$eventLogger->end('boot');
+ $eventLogger->log('init', 'OC::init', $loaderStart, microtime(true));
}
/**
diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php
index 6e05b7fdc88..b6378830732 100644
--- a/lib/private/AppFramework/Bootstrap/Coordinator.php
+++ b/lib/private/AppFramework/Bootstrap/Coordinator.php
@@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OC\AppFramework\Bootstrap;
+use OCP\Diagnostics\IEventLogger;
use function class_exists;
use function class_implements;
use function in_array;
@@ -58,6 +59,9 @@ class Coordinator {
/** @var IEventDispatcher */
private $eventDispatcher;
+ /** @var IEventLogger */
+ private $eventLogger;
+
/** @var LoggerInterface */
private $logger;
@@ -72,12 +76,14 @@ class Coordinator {
Registry $registry,
IManager $dashboardManager,
IEventDispatcher $eventListener,
+ IEventLogger $eventLogger,
LoggerInterface $logger
) {
$this->serverContainer = $container;
$this->registry = $registry;
$this->dashboardManager = $dashboardManager;
$this->eventDispatcher = $eventListener;
+ $this->eventLogger = $eventLogger;
$this->logger = $logger;
}
@@ -126,7 +132,9 @@ class Coordinator {
continue;
}
+ $this->eventLogger->start('bootstrap:register_app_' . $appId, '');
$application->register($this->registrationContext->for($appId));
+ $this->eventLogger->end('bootstrap:register_app_' . $appId);
}
} catch (Throwable $e) {
$this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [
@@ -172,6 +180,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, '');
try {
/** @var App $application */
$application = $this->serverContainer->query($applicationClassName);
@@ -189,6 +198,7 @@ class Coordinator {
'exception' => $e,
]);
}
+ $this->eventLogger->end('bootstrap:boot_app_' . $appId);
}
public function isBootable(string $appId) {
diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php
index edaa4bc0d50..02867b3b4b7 100644
--- a/lib/private/Diagnostics/EventLogger.php
+++ b/lib/private/Diagnostics/EventLogger.php
@@ -72,7 +72,7 @@ class EventLogger implements IEventLogger {
/**
* @inheritdoc
*/
- public function start($id, $description) {
+ public function start($id, $description = '') {
if ($this->activated) {
$this->events[$id] = new Event($id, $description, microtime(true));
$this->writeLog($this->events[$id]);
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 1ce3662000e..ca01e91216b 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -173,6 +173,7 @@ 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,
@@ -181,7 +182,6 @@ class OC_App {
\OC::$server->getLogger()->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
'app' => $app,
]);
- \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app);
try {
self::requireAppFile($app);
} catch (Throwable $ex) {
@@ -201,8 +201,9 @@ class OC_App {
]);
}
}
- \OC::$server->getEventLogger()->end('load_app_' . $app);
}
+ \OC::$server->getEventLogger()->end('bootstrap:load_app_' . $app);
+
$coordinator->bootApp($app);
$info = self::getAppInfo($app);
diff --git a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
index d6ceefa4268..5a151806adf 100644
--- a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
+++ b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
@@ -34,6 +34,7 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\QueryException;
use OCP\Dashboard\IManager;
+use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use PHPUnit\Framework\MockObject\MockObject;
@@ -57,6 +58,9 @@ class CoordinatorTest extends TestCase {
/** @var IEventDispatcher|MockObject */
private $eventDispatcher;
+ /** @var IEventLogger|MockObject */
+ private $eventLogger;
+
/** @var LoggerInterface|MockObject */
private $logger;
@@ -71,6 +75,7 @@ class CoordinatorTest extends TestCase {
$this->crashReporterRegistry = $this->createMock(Registry::class);
$this->dashboardManager = $this->createMock(IManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->eventLogger = $this->createMock(IEventLogger::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->coordinator = new Coordinator(
@@ -78,6 +83,7 @@ class CoordinatorTest extends TestCase {
$this->crashReporterRegistry,
$this->dashboardManager,
$this->eventDispatcher,
+ $this->eventLogger,
$this->logger
);
}