mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
feat: log outstandingRequests
This commit is contained in:
parent
eab96b2d6e
commit
eee910a512
1 changed files with 11 additions and 1 deletions
|
@ -10,9 +10,12 @@ interface HostStats {
|
|||
|
||||
let stats: Record<string, number[]> = {};
|
||||
|
||||
let outstandingRequests = {};
|
||||
|
||||
// istanbul ignore next
|
||||
export const resetStats = (): void => {
|
||||
stats = {};
|
||||
outstandingRequests = {};
|
||||
};
|
||||
|
||||
// istanbul ignore next
|
||||
|
@ -30,15 +33,22 @@ export const printStats = (): void => {
|
|||
res.median = entries[Math.floor(entries.length / 2)];
|
||||
hostStats[hostname] = res;
|
||||
}
|
||||
logger.debug({ hostStats }, 'Host request stats (milliseconds)');
|
||||
logger.debug(
|
||||
{ hostStats, outstandingRequests },
|
||||
'Host request stats (milliseconds)'
|
||||
);
|
||||
};
|
||||
|
||||
export const instance = create({
|
||||
options: {},
|
||||
handler: (options, next) => {
|
||||
const request = `${options.method} ${options.href}`;
|
||||
logger.info(request);
|
||||
outstandingRequests[request] = true;
|
||||
const start = new Date();
|
||||
const nextPromise = next(options);
|
||||
nextPromise.on('response', () => {
|
||||
delete outstandingRequests[request];
|
||||
const elapsed = new Date().getTime() - start.getTime();
|
||||
stats[options.hostname] = stats[options.hostname] || [];
|
||||
stats[options.hostname].push(elapsed);
|
||||
|
|
Loading…
Reference in a new issue