Skip to content

Commit

Permalink
Merge pull request #36 from Kanti/bugfix/staticfilecache-spatie_asnyc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti authored Sep 12, 2023
2 parents 529a15d + 763634e commit cb9d888
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Classes/EventListener/BootCompletedEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 8 additions & 3 deletions Classes/Utility/GuzzleUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cb9d888

Please sign in to comment.