aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/Connection.php
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-01-19 23:30:34 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-04-04 10:28:26 +0200
commit7d272c54d013538746d6731097ec37f360effb5d (patch)
treed754c4184926ea8011bd2b0fe276adebaf4082f6 /lib/private/DB/Connection.php
parentcf4c77e064fd52d891bc842d78431cceb2f34952 (diff)
downloadnextcloud-server-7d272c54d013538746d6731097ec37f360effb5d.tar.gz
nextcloud-server-7d272c54d013538746d6731097ec37f360effb5d.zip
Add a built-in profiler inside Nextcloud
The webui is provided by a seperate application named profiler Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/private/DB/Connection.php')
-rw-r--r--lib/private/DB/Connection.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index 0cd310550b6..2e38b1ddf5e 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -42,6 +42,7 @@ use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\ConstraintViolationException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
+use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
@@ -55,6 +56,7 @@ use OCP\PreConditionNotMetException;
use OC\DB\QueryBuilder\QueryBuilder;
use OC\SystemConfig;
use Psr\Log\LoggerInterface;
+use OCP\Profiler\IProfiler;
class Connection extends \Doctrine\DBAL\Connection {
/** @var string */
@@ -76,6 +78,9 @@ class Connection extends \Doctrine\DBAL\Connection {
/** @var int */
protected $queriesExecuted = 0;
+ /** @var DbDataCollector|null */
+ protected $dbDataCollector = null;
+
/**
* Initializes a new instance of the Connection class.
*
@@ -102,6 +107,16 @@ class Connection extends \Doctrine\DBAL\Connection {
$this->systemConfig = \OC::$server->getSystemConfig();
$this->logger = \OC::$server->get(LoggerInterface::class);
+
+ /** @var \OCP\Profiler\IProfiler */
+ $profiler = \OC::$server->get(IProfiler::class);
+ if ($profiler->isEnabled()) {
+ $this->dbDataCollector = new DbDataCollector($this);
+ $profiler->add($this->dbDataCollector);
+ $debugStack = new DebugStack();
+ $this->dbDataCollector->setDebugStack($debugStack);
+ $this->_config->setSQLLogger($debugStack);
+ }
}
/**