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);
|
requestHosts[hostname].push(httpRequest);
|
||||||
}
|
}
|
||||||
logger.trace({ allRequests, requestHosts }, 'full stats');
|
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;
|
let totalRequests = 0;
|
||||||
for (const [hostname, requests] of Object.entries(requestHosts)) {
|
for (const [hostname, requests] of Object.entries(requestHosts)) {
|
||||||
const hostRequests = requests.length;
|
const requestCount = requests.length;
|
||||||
totalRequests += hostRequests;
|
totalRequests += requestCount;
|
||||||
const requestSum = requests
|
const requestSum = requests
|
||||||
.map(({ duration }) => duration)
|
.map(({ duration }) => duration)
|
||||||
.reduce((a, b) => a + b, 0);
|
.reduce((a, b) => a + b, 0);
|
||||||
const requestAvg = Math.round(requestSum / hostRequests);
|
const requestAvgMs = Math.round(requestSum / requestCount);
|
||||||
|
|
||||||
const queueSum = requests
|
const queueSum = requests
|
||||||
.map(({ queueDuration }) => queueDuration)
|
.map(({ queueDuration }) => queueDuration)
|
||||||
.reduce((a, b) => a + b, 0);
|
.reduce((a, b) => a + b, 0);
|
||||||
const queueAvg = Math.round(queueSum / hostRequests);
|
const queueAvgMs = Math.round(queueSum / requestCount);
|
||||||
const requestCount =
|
hostStats[hostname] = { requestCount, requestAvgMs, queueAvgMs };
|
||||||
`${hostRequests} ` + (hostRequests > 1 ? 'requests' : 'request');
|
|
||||||
hostStats.push(
|
|
||||||
`${hostname}, ${requestCount}, ${requestAvg}ms request average, ${queueAvg}ms queue average`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
logger.debug({ hostStats, totalRequests }, 'http statistics');
|
logger.debug({ hostStats, totalRequests }, 'http statistics');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue