The big response time number is labelled last check. ClientErrorClassifier tells smoke and curl test reports and bot reports apart; tests are counted separately and left out of the tile, the hourly bars, the list and the dashboard tile, bots keep a label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Evomedien\Vitec\Service;
|
|
|
|
/**
|
|
* Tells test reports and bot reports in tx_vitec_clienterrorlog apart
|
|
* from real visitor errors (ticket 0114-FE: the cockpit tile must not
|
|
* count smoke tests). One rule set for the module and the dashboard.
|
|
*
|
|
* Test: sent with curl, a user agent that says "smoke" or "client-error
|
|
* test", a message starting with "test", or the dummy release "t" of the
|
|
* endpoint smoke test. Bot: a crawler user agent (Googlebot & Co.); bot
|
|
* reports stay real errors, they only get a label.
|
|
*/
|
|
final class ClientErrorClassifier
|
|
{
|
|
public static function isTest(string $message, string $userAgent, string $release = ''): bool
|
|
{
|
|
if ($release === 't') {
|
|
return true;
|
|
}
|
|
if (preg_match('#curl/|smoke|client-error test#i', $userAgent) === 1) {
|
|
return true;
|
|
}
|
|
return preg_match('#^\s*test\b#i', $message) === 1;
|
|
}
|
|
|
|
public static function isBot(string $userAgent): bool
|
|
{
|
|
return preg_match('#bot\b|crawler|spider|slurp|lighthouse|headlesschrome#i', $userAgent) === 1;
|
|
}
|
|
|
|
public static function isChunkReload(string $message): bool
|
|
{
|
|
return str_contains(strtolower($message), 'chunk reload');
|
|
}
|
|
}
|