mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix: semantic host stats (#11482)
This commit is contained in:
parent
60b3d6d933
commit
59cc317156
1 changed files with 11 additions and 10 deletions
|
@ -30,25 +30,26 @@ export function printRequestStats(): void {
|
|||
requestHosts[hostname].push(httpRequest);
|
||||
}
|
||||
logger.trace({ allRequests, requestHosts }, 'full stats');
|
||||
const hostStats: string[] = [];
|
||||
type HostStats = {
|
||||
requestCount: number;
|
||||
requestAvgMs: number;
|
||||
queueAvgMs: number;
|
||||
};
|
||||
const hostStats: Record<string, HostStats> = {};
|
||||
let totalRequests = 0;
|
||||
for (const [hostname, requests] of Object.entries(requestHosts)) {
|
||||
const hostRequests = requests.length;
|
||||
totalRequests += hostRequests;
|
||||
const requestCount = requests.length;
|
||||
totalRequests += requestCount;
|
||||
const requestSum = requests
|
||||
.map(({ duration }) => duration)
|
||||
.reduce((a, b) => a + b, 0);
|
||||
const requestAvg = Math.round(requestSum / hostRequests);
|
||||
const requestAvgMs = Math.round(requestSum / requestCount);
|
||||
|
||||
const queueSum = requests
|
||||
.map(({ queueDuration }) => queueDuration)
|
||||
.reduce((a, b) => a + b, 0);
|
||||
const queueAvg = Math.round(queueSum / hostRequests);
|
||||
const requestCount =
|
||||
`${hostRequests} ` + (hostRequests > 1 ? 'requests' : 'request');
|
||||
hostStats.push(
|
||||
`${hostname}, ${requestCount}, ${requestAvg}ms request average, ${queueAvg}ms queue average`
|
||||
);
|
||||
const queueAvgMs = Math.round(queueSum / requestCount);
|
||||
hostStats[hostname] = { requestCount, requestAvgMs, queueAvgMs };
|
||||
}
|
||||
logger.debug({ hostStats, totalRequests }, 'http statistics');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue