SSR cockpit: label the response time, leave test reports out of the client error counts (0114-FE)
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>
This commit is contained in:
1 parent
4bc38b1760
commit
06b9bc8293
5 files changed
+125
-41
No files matched your search
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Evomedien\Vitec\Widgets;
|
||||
|
||||
use Evomedien\Vitec\Service\ClientErrorClassifier;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
|
||||
@@ -35,9 +36,9 @@ final class SsrStatsWidget implements WidgetInterface, AdditionalCssInterface
|
||||
$full7d = $this->count('tx_vitec_ssrpurgelog', "crdate > " . $d7 . " AND paths = '*'");
|
||||
$avgMs = $this->scalar('SELECT ROUND(AVG(response_ms)) FROM tx_vitec_ssrhealthlog WHERE crdate > ' . $d1 . ' AND ok = 1');
|
||||
$maxCache = $this->scalar('SELECT MAX(cache_mb) FROM tx_vitec_ssrhealthlog WHERE crdate > ' . $d7);
|
||||
// Browser-side errors reported via POST /api/vitec/client-error.
|
||||
$clientErrors24h = $this->count('tx_vitec_clienterrorlog', 'crdate > ' . $d1);
|
||||
$clientErrors7d = $this->count('tx_vitec_clienterrorlog', 'crdate > ' . $d7);
|
||||
// Browser-side errors reported via POST /api/vitec/client-error,
|
||||
// without smoke/curl test reports (0114-FE).
|
||||
[$clientErrors24h, $clientErrors7d] = $this->realClientErrors($d1, $d7);
|
||||
|
||||
$strip = $h::strip($this->connectionPool);
|
||||
$uptime = $strip['uptime'];
|
||||
@@ -59,7 +60,7 @@ final class SsrStatsWidget implements WidgetInterface, AdditionalCssInterface
|
||||
. $tile('Failed purges', (string)$failed7d, 'last 7 days', $failed7d > 0 ? 'vcw-bad' : 'vcw-ok')
|
||||
. $tile('Avg. response', $avgMs !== null ? $avgMs . '<small>ms</small>' : '–', 'last 24 h')
|
||||
. $tile('Max. cache', $maxCache !== null ? $maxCache . '<small>MB</small>' : '–', 'last 7 days')
|
||||
. $tile('Client errors', $clientErrors24h . '<small>/ ' . $clientErrors7d . '</small>', '24 h / 7 days', $clientErrors24h > 0 ? 'vcw-warn' : 'vcw-ok')
|
||||
. $tile('Client errors', $clientErrors24h . '<small>/ ' . $clientErrors7d . '</small>', '24 h / 7 days, no tests', $clientErrors24h > 0 ? 'vcw-warn' : 'vcw-ok')
|
||||
. '</div>';
|
||||
|
||||
if ($strip['samples'] === 0) {
|
||||
@@ -82,6 +83,31 @@ final class SsrStatsWidget implements WidgetInterface, AdditionalCssInterface
|
||||
return [CockpitHtml::CSS];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: int, 1: int} real client error reports in 24 h / 7 days
|
||||
*/
|
||||
private function realClientErrors(int $d1, int $d7): array
|
||||
{
|
||||
try {
|
||||
$rows = $this->connectionPool->getConnectionForTable('tx_vitec_clienterrorlog')->executeQuery(
|
||||
'SELECT crdate, message, user_agent, `release` FROM tx_vitec_clienterrorlog WHERE crdate > ?',
|
||||
[$d7]
|
||||
)->fetchAllAssociative();
|
||||
} catch (\Throwable) {
|
||||
return [0, 0];
|
||||
}
|
||||
$day = 0;
|
||||
$week = 0;
|
||||
foreach ($rows as $r) {
|
||||
if (ClientErrorClassifier::isTest((string)$r['message'], (string)$r['user_agent'], (string)$r['release'])) {
|
||||
continue;
|
||||
}
|
||||
$week++;
|
||||
$day += (int)$r['crdate'] > $d1 ? 1 : 0;
|
||||
}
|
||||
return [$day, $week];
|
||||
}
|
||||
|
||||
private function count(string $table, string $where): int
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user