mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
feat: log RAM usage over a hard coded threshold
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
5be832344e
commit
fed340324a
1 changed files with 10 additions and 1 deletions
11
lib/base.php
11
lib/base.php
|
|
@ -817,8 +817,17 @@ class OC {
|
|||
$eventLogger->log('init', 'OC::init', $loaderStart, microtime(true));
|
||||
$eventLogger->start('runtime', 'Runtime');
|
||||
$eventLogger->start('request', 'Full request after boot');
|
||||
register_shutdown_function(function () use ($eventLogger) {
|
||||
|
||||
$logger = \OCP\Server::get(\Psr\Log\LoggerInterface::class);
|
||||
register_shutdown_function(function () use ($eventLogger, $request, $logger) {
|
||||
$eventLogger->end('request');
|
||||
$memoryInMiB = memory_get_peak_usage(true) / 1024 / 1024;
|
||||
if ($memoryInMiB > 150) {
|
||||
$logger->warning('This request peaked in {memory} MiB memory usage', [
|
||||
'memory' => $memoryInMiB,
|
||||
'parameters' => $request->getParams(),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue