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

made length of descriptions and number of timings configurable in bac… #41

Merged
merged 5 commits into from
Feb 9, 2024
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
20 changes: 20 additions & 0 deletions Classes/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
/** @var int */
private const DEFAULT_STOP_WATCH_LIMIT = 100_000;

/**
* @var int
*/
private const DEFAULT_DESCRIPTION_LENGTH = 100;

/**
* @var int
*/
private const DEFAULT_NUMBER_TIMINGS = 30;

public function stopWatchLimit(): int
{
return (int)($this->getConfig('stop_watch_limit') ?: self::DEFAULT_STOP_WATCH_LIMIT);
Expand All @@ -28,6 +38,16 @@
return $tracesSampleRate === null ? null : (bool)$tracesSampleRate;
}

public function getDescriptionLength(): int
{
return (int)($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH);

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {

Check warning on line 43 in Classes/Service/ConfigService.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ } public function getDescriptionLength() : int { - return (int) ($this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH); + return $this->getConfig('length_of_description') ?: self::DEFAULT_DESCRIPTION_LENGTH; } public function getMaxNumberOfTimings() : int {
}

public function getMaxNumberOfTimings(): int

Check warning on line 46 in Classes/Service/ConfigService.php

View check run for this annotation

Codecov / codecov/patch

Classes/Service/ConfigService.php#L46

Added line #L46 was not covered by tests
{
return (int)($this->getConfig('number_of_timings') ?: self::DEFAULT_NUMBER_TIMINGS);

Check warning on line 48 in Classes/Service/ConfigService.php

View check run for this annotation

Codecov / codecov/patch

Classes/Service/ConfigService.php#L48

Added line #L48 was not covered by tests
}

private function getConfig(string $path): string
{
return (string)($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['server_timing'][$path] ?? '');
Expand Down
19 changes: 14 additions & 5 deletions Classes/Utility/TimingUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public static function getInstance(): TimingUtility
{
return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class);

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 11 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 11 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.2 TYPO3: 12 sentry/sdk: false

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];

Check warning on line 37 in Classes/Utility/TimingUtility.php

View workflow job for this annotation

GitHub Actions / php: 8.1 TYPO3: 12 sentry/sdk: true

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ } public static function getInstance() : TimingUtility { - return static::$instance ??= GeneralUtility::makeInstance(TimingUtility::class); + return static::$instance = GeneralUtility::makeInstance(TimingUtility::class); } /** @var StopWatch[] */ private array $order = [];
}

/** @var StopWatch[] */
Expand Down Expand Up @@ -138,12 +138,21 @@
}

$timings = [];
foreach ($this->combineIfToMuch($this->order) as $index => $time) {
$timings[] = $this->timingString($index, trim($time->key . ' ' . $time->info), $time->getDuration());
$durations = [];
$stopWatches = $this->combineIfToMuch($this->order);

Check warning on line 142 in Classes/Utility/TimingUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/TimingUtility.php#L141-L142

Added lines #L141 - L142 were not covered by tests

foreach ($stopWatches as $stopwatch) {
$durations[] = $stopwatch->getDuration();

Check warning on line 145 in Classes/Utility/TimingUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/TimingUtility.php#L144-L145

Added lines #L144 - L145 were not covered by tests
}

if (count($timings) > 70) {
$timings = [$this->timingString(0, 'To Many measurements ' . count($timings), 0.000001)];
rsort($durations);

Check warning on line 148 in Classes/Utility/TimingUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/TimingUtility.php#L148

Added line #L148 was not covered by tests

$maxNumberOfTimings = $durations[$this->configService->getMaxNumberOfTimings() - 1] ?? 0;
foreach ($stopWatches as $index => $time) {
$duration = $time->getDuration();
if ($duration >= $maxNumberOfTimings) {
$timings[] = $this->timingString($index, trim($time->key . ' ' . $time->info . ' ' . $duration), $duration);

Check warning on line 154 in Classes/Utility/TimingUtility.php

View check run for this annotation

Codecov / codecov/patch

Classes/Utility/TimingUtility.php#L150-L154

Added lines #L150 - L154 were not covered by tests
}
}


Expand Down Expand Up @@ -237,7 +246,7 @@

private function timingString(int $index, string $description, float $durationInSeconds): string
{
$description = substr($description, 0, 100);
$description = substr($description, 0, $this->configService->getDescriptionLength());
$description = str_replace(['\\', '"', ';', "\r", "\n"], ["_", "'", ",", "", ""], $description);
return sprintf('%03d;desc="%s";dur=%0.2f', $index, $description, $durationInSeconds * 1000);
}
Expand Down
6 changes: 6 additions & 0 deletions ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ sentry_sample_rate =

# cat=sentry; type=string; label=Sentry CLI Sample Rate between 0.0 and 1.0 (empty: keep default)
sentry_cli_sample_rate =

# cat=sentry; type=integer; label=Number of timings (reduce to make header output smaller. Try out when you get regularly 502 responses).
number_of_timings = 30

# cat=sentry; type=integer; label=Length of description (reduce to make header output smaller. Try out when you get regularly 502 responses).
length_of_description = 100
CamillH marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"text": "Resources/Public/test-result/infection.log",
"html": "Resources/Public/test-result/infection.html"
},
"minCoveredMsi": 98,
"minCoveredMsi": 95,
"initialTestsPhpOptions": "-d pcov.enabled=1",
"mutators": {
"@default": true
Expand Down
Loading