Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -0,0 +1,242 @@
<?php
declare(strict_types=1);
namespace App\Application\Performance\Http\Controller;
use App\Framework\Attributes\Route;
use App\Framework\Core\ValueObjects\Byte;
use App\Framework\Http\Method;
use App\Framework\Performance\MemoryMonitor;
use App\Framework\Performance\PerformanceService;
use App\Framework\Router\Result\JsonResult;
final class PerformanceController
{
public function __construct(
private PerformanceService $performanceService,
) {
}
#[Route(path: '/admin/performance/summary', method: Method::GET)]
public function getSummary(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
return new JsonResult([
'success' => true,
'data' => $this->performanceService->getSummary(),
]);
}
#[Route(path: '/admin/performance/metrics', method: Method::GET)]
public function getMetrics(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
$category = $_GET['category'] ?? null;
$categoryFilter = $category ? \App\Framework\Performance\PerformanceCategory::tryFrom($category) : null;
return new JsonResult([
'success' => true,
'data' => $this->performanceService->getMetrics($categoryFilter),
]);
}
#[Route(path: '/admin/performance/slowest', method: Method::GET)]
public function getSlowestOperations(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
$limit = (int) ($_GET['limit'] ?? 10);
return new JsonResult([
'success' => true,
'data' => $this->performanceService->getSlowestOperations($limit),
]);
}
#[Route(path: '/admin/performance/report', method: Method::GET)]
public function getReport(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
$format = $_GET['format'] ?? 'array';
return new JsonResult([
'success' => true,
'data' => $this->performanceService->generateReport($format),
]);
}
#[Route(path: '/admin/performance/stats', method: Method::GET)]
public function getRequestStats(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
return new JsonResult([
'success' => true,
'data' => $this->performanceService->getRequestStats(),
]);
}
#[Route(path: '/admin/performance/reset', method: Method::POST)]
public function resetMetrics(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
$this->performanceService->reset();
return new JsonResult([
'success' => true,
'message' => 'Performance metrics have been reset',
]);
}
#[Route(path: '/admin/performance/memory', method: Method::GET)]
public function getMemoryStats(): JsonResult
{
$memoryMonitor = new MemoryMonitor();
$summary = $memoryMonitor->getSummary();
// Add additional memory information
$data = $summary->toArray();
$data['php_info'] = [
'memory_limit' => [
'raw' => ini_get('memory_limit'),
'bytes' => $memoryMonitor->getMemoryLimit()->toBytes(),
'human' => $memoryMonitor->getMemoryLimit()->toHumanReadable(),
],
'max_execution_time' => ini_get('max_execution_time'),
'upload_max_filesize' => [
'raw' => ini_get('upload_max_filesize'),
'bytes' => Byte::parse(ini_get('upload_max_filesize'))->toBytes(),
'human' => Byte::parse(ini_get('upload_max_filesize'))->toHumanReadable(),
],
'post_max_size' => [
'raw' => ini_get('post_max_size'),
'bytes' => Byte::parse(ini_get('post_max_size'))->toBytes(),
'human' => Byte::parse(ini_get('post_max_size'))->toHumanReadable(),
],
];
return new JsonResult([
'success' => true,
'data' => $data,
]);
}
#[Route(path: '/admin/performance/system', method: Method::GET)]
public function getSystemInfo(): JsonResult
{
$memoryMonitor = new MemoryMonitor();
$systemInfo = [
'php' => [
'version' => PHP_VERSION,
'sapi' => PHP_SAPI,
'os' => PHP_OS,
'architecture' => php_uname('m'),
],
'memory' => $memoryMonitor->getSummary()->toArray(),
'opcache' => function_exists('opcache_get_status') ? opcache_get_status() : null,
'extensions' => [
'apcu' => extension_loaded('apcu'),
'redis' => extension_loaded('redis'),
'imagick' => extension_loaded('imagick'),
'gd' => extension_loaded('gd'),
'curl' => extension_loaded('curl'),
'zip' => extension_loaded('zip'),
],
];
// Add disk space information if available
if (function_exists('disk_free_space') && function_exists('disk_total_space')) {
$rootPath = '/';
$freeBytes = disk_free_space($rootPath);
$totalBytes = disk_total_space($rootPath);
if ($freeBytes !== false && $totalBytes !== false) {
$usedBytes = $totalBytes - $freeBytes;
$systemInfo['disk'] = [
'free' => [
'bytes' => $freeBytes,
'human' => Byte::fromBytes((int) $freeBytes)->toHumanReadable(),
],
'used' => [
'bytes' => $usedBytes,
'human' => Byte::fromBytes((int) $usedBytes)->toHumanReadable(),
],
'total' => [
'bytes' => $totalBytes,
'human' => Byte::fromBytes((int) $totalBytes)->toHumanReadable(),
],
'usage_percentage' => round(($usedBytes / $totalBytes) * 100, 2),
];
}
}
return new JsonResult([
'success' => true,
'data' => $systemInfo,
]);
}
#[Route(path: '/admin/performance/config', method: Method::GET)]
public function getConfig(): JsonResult
{
return new JsonResult([
'success' => true,
'data' => [
'enabled' => $this->performanceService->isEnabled(),
'config' => $this->performanceService->getConfig(),
],
]);
}
#[Route(path: '/admin/performance/export', method: Method::GET)]
public function exportMetrics(): JsonResult
{
if (! $this->performanceService->isEnabled()) {
return new JsonResult([
'success' => false,
'error' => 'Performance monitoring is disabled',
]);
}
return new JsonResult([
'success' => true,
'data' => $this->performanceService->exportMetrics(),
]);
}
}