Skip to content
Permalink
Browse files
feat: log urls in closing stats (#11798)
  • Loading branch information
rarkins committed Sep 17, 2021
1 parent 88fd874 commit 66bc2528f57705fa51a88a9216952364359da555
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/workers/repository/stats.ts
@@ -20,15 +20,29 @@ export function printRequestStats(): void {
});
const allRequests: string[] = [];
const requestHosts: Record<string, RequestStats[]> = {};
const rawUrls: Record<string, number> = {};
for (const httpRequest of httpRequests) {
const { method, url, duration, queueDuration } = httpRequest;
const [baseUrl] = url.split('?');
// put method last for better sorting
const urlKey = `${baseUrl} (${method.toUpperCase()})`;
if (rawUrls[urlKey]) {
rawUrls[urlKey] += 1;
} else {
rawUrls[urlKey] = 1;
}
allRequests.push(
`${method.toUpperCase()} ${url} ${duration} ${queueDuration}`
);
const { hostname } = URL.parse(url);
requestHosts[hostname] = requestHosts[hostname] || [];
requestHosts[hostname].push(httpRequest);
}
const urls: Record<string, number> = {};
// Sort urls for easier reading
for (const url of Object.keys(rawUrls).sort()) {
urls[url] = rawUrls[url];
}
logger.trace({ allRequests, requestHosts }, 'full stats');
type HostStats = {
requestCount: number;
@@ -51,5 +65,5 @@ export function printRequestStats(): void {
const queueAvgMs = Math.round(queueSum / requestCount);
hostStats[hostname] = { requestCount, requestAvgMs, queueAvgMs };
}
logger.debug({ hostStats, totalRequests }, 'http statistics');
logger.debug({ urls, hostStats, totalRequests }, 'http statistics');
}

0 comments on commit 66bc252

Please sign in to comment.