Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix compatibility with spatie/async and staticfilecache #36

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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);

Check warning on line 27 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L26-L27

Added lines #L26 - L27 were not covered by tests

return static fn(callable $handler): Closure => static function (RequestInterface $request, array $options) use ($sentryService, $timingUtility, $handler): PromiseInterface {

Check warning on line 29 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L29

Added line #L29 was not covered by tests
$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);

Check warning on line 32 in Classes/Utility/GuzzleUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/GuzzleUtility.php#L31-L32

Added lines #L31 - L32 were not covered by tests

$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
Loading