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

@@ -8,23 +8,27 @@ use App\Framework\Core\DynamicRoute;
use App\Framework\DI\DefaultContainer;
use App\Framework\Http\Response;
use App\Framework\Http\Responses\NotFound;
use App\Framework\Router\Result\ContentNegotiationResult;
use App\Framework\Performance\Contracts\PerformanceServiceInterface;
use App\Framework\Performance\PerformanceCategory;
final readonly class RouteDispatcher
{
public function __construct(
private DefaultContainer $container,
private ParameterProcessor $parameterProcessor
) {}
private ParameterProcessor $parameterProcessor,
private PerformanceServiceInterface $performanceService
) {
}
/**
* Verarbeitet eine Route und führt den entsprechenden Controller-Action aus
* Verarbeitet eine Route und führt die entsprechende Controller-Action aus
*/
public function dispatch(RouteContext $routeContext): ActionResult|Response
{
$routeMatch = $routeContext->match;
if ($routeMatch->isMatch()) {
/** @var RouteMatchSuccess $routeMatch */
return $this->executeController($routeMatch);
}
@@ -33,23 +37,50 @@ final readonly class RouteDispatcher
/**
* Führt die Controller-Action mit den aufbereiteten Parametern aus
* @param RouteMatchSuccess $routeMatch
* @return ActionResult|Response
*/
private function executeController(RouteMatch $routeMatch): ActionResult|Response
{
$controller = $routeMatch->route->controller;
$action = $routeMatch->route->action;
$params = $routeMatch->route->parameters;
$queryParams = [];
if($routeMatch->route instanceof DynamicRoute) {
if ($routeMatch->route instanceof DynamicRoute) {
$queryParams = $routeMatch->route->paramValues;
}
$preparedParams = $this->parameterProcessor->prepareParameters($params, $queryParams);
// Use type-safe parameter collection if available, fallback to legacy array
$parameterCollection = $routeMatch->route->getParameterCollection();
$preparedParams = $this->performanceService->measure(
'parameter_preparation',
fn () => $this->parameterProcessor->prepareParametersFromCollection($parameterCollection, $queryParams),
PerformanceCategory::CONTROLLER,
[
'controller' => $controller,
'action' => $action,
'param_count' => $parameterCollection->count(),
]
);
$controllerInstance = $this->container->get($controller);
$result = $controllerInstance->$action(...$preparedParams);
// Measure controller instantiation
$controllerInstance = $this->performanceService->measure(
'controller_instantiation',
fn () => $this->container->get($controller), /** @phpstan-ignore argument.type */
PerformanceCategory::CONTROLLER,
['controller' => $controller]
);
// Measure actual controller method execution
$result = $this->performanceService->measure(
'controller_execution',
fn () => $controllerInstance->$action(...$preparedParams),
PerformanceCategory::CONTROLLER,
[
'controller' => $controller,
'action' => $action,
]
);
if ($result instanceof Response || $result instanceof ActionResult) {
return $result;