Skip to content

Commit

Permalink
✨ add fileProcessing measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Oct 18, 2023
1 parent 6a464ee commit dad4f66
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
29 changes: 29 additions & 0 deletions Classes/EventListener/FileProcessingEventListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Kanti\ServerTiming\EventListener;

use Kanti\ServerTiming\Dto\StopWatch;
use Kanti\ServerTiming\Utility\TimingUtility;
use TYPO3\CMS\Core\Resource\Event\AfterFileProcessingEvent;
use TYPO3\CMS\Core\Resource\Event\BeforeFileProcessingEvent;

final class FileProcessingEventListener
{
public StopWatch|null $stopWatch = null;

public function before(BeforeFileProcessingEvent $event): void
{
if (!$event->getProcessedFile()->isProcessed()) {
$this->stopWatch?->stopIfNot();
$this->stopWatch = TimingUtility::stopWatch('fileProcessing', $event->getProcessedFile()->getName());
}
}

public function after(AfterFileProcessingEvent $event): void
{
$this->stopWatch?->stopIfNot();
$this->stopWatch = null;
}
}
15 changes: 14 additions & 1 deletion Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ services:
identifier: kanti/server-timing/mail-event-listener
event: TYPO3\CMS\Core\Mail\Event\AfterMailerSentMessageEvent
method: stop

Kanti\ServerTiming\EventListener\BootCompletedEventListener:
tags:
-
name: event.listener
identifier: kanti/server-timing/boot-completed-event-listener
event: TYPO3\CMS\Core\Core\Event\BootCompletedEvent

Kanti\ServerTiming\EventListener\FileProcessingEventListener:
tags:
-
name: event.listener
identifier: kanti/server-timing/file-processing
event: TYPO3\CMS\Core\Resource\Event\BeforeFileProcessingEvent
method: before

-
name: event.listener
identifier: kanti/server-timing/file-processing
event: TYPO3\CMS\Core\Resource\Event\AfterFileProcessingEvent
method: after
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ at the moment there is nothing to configure
- `mail`: shows the mails that are send (only TYPO3 >=12)
- `dataP`: Shows the DataProcessors that were executed
- `extbase`: show all Extbase dispatches, (forwards are included in the original action call)
- `fileProcessing`: show all file processing calls
- `http.client`: external API calls are measured if they use the official TYPO3 `RequestFactory` or the `GuzzleClientFactory`)

> if a measurement key has more than 4 entries, they will get combined into one total time with a count.
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
},
"config": {
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true,
"phpro/grumphp": true,
"pluswerk/grumphp-config": true,
"ergebnis/composer-normalize": true,
"infection/extension-installer": true,
"php-http/discovery": false,
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true,
"php-http/discovery": false
"pluswerk/grumphp-config": true,
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true
}
},
"extra": {
Expand Down

0 comments on commit dad4f66

Please sign in to comment.