diff --git a/Classes/EventListener/BootCompletedEventListener.php b/Classes/EventListener/BootCompletedEventListener.php index 111690a..e3f7b3d 100644 --- a/Classes/EventListener/BootCompletedEventListener.php +++ b/Classes/EventListener/BootCompletedEventListener.php @@ -14,7 +14,7 @@ public function __invoke(BootCompletedEvent $event): void { // we initialize TimingUtility here // in the install tool, (eg. DB compare) - // at this point, the TimingUtility is found in the container, but at the shutdown state the TimingUtility is not found in the conatiner. + // at this point, the TimingUtility is found in the container, but at the shutdown state the TimingUtility is not found in the container. // so if we initialize it right here and save it inside a static variable, then everything works as expected. (not the sentry part :/ ) TimingUtility::getInstance(); SqlLoggerCore11::registerSqlLogger(); diff --git a/Classes/Utility/GuzzleUtility.php b/Classes/Utility/GuzzleUtility.php index 24b8225..0701467 100644 --- a/Classes/Utility/GuzzleUtility.php +++ b/Classes/Utility/GuzzleUtility.php @@ -21,10 +21,15 @@ public static function getHandler(): ?Closure return null; } - return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($handler): PromiseInterface { + // initialize early: so the spatie/async with staticfilecache doesn't kill the process + // there is the problem that it has a subprocess where the Container is not initialized fully + $timingUtility = TimingUtility::getInstance(); + $sentryService = GeneralUtility::makeInstance(SentryService::class); + + return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($sentryService, $timingUtility, $handler): PromiseInterface { $info = $request->getMethod() . ' ' . $request->getUri()->__toString(); - $stop = TimingUtility::stopWatch('http.client', $info); - $request = GeneralUtility::makeInstance(SentryService::class)->addSentryTraceHeaders($request, $stop); + $stop = $timingUtility->stopWatchInternal('http.client', $info); + $request = $sentryService->addSentryTraceHeaders($request, $stop); $handlerPromiseCallback = static function ($responseOrException) use ($request, $stop) { $response = null; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 3e427ed..9828303 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -10,6 +10,7 @@ services: - '../Classes/{Dto,SqlLogging}/*' - '../Classes/*/WrapMiddleware.php' - '../Classes/*/XClassMiddlewareDispatcher.php' + Kanti\ServerTiming\Service\RegisterShutdownFunction\RegisterShutdownFunctionInterface: class: Kanti\ServerTiming\Service\RegisterShutdownFunction\RegisterShutdownFunction