Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log urls in closing stats #11798

Merged
merged 1 commit into from Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/workers/repository/stats.ts
Expand Up @@ -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;
Expand All @@ -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');
}