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 stats: Record<string, number[]> = {};
|
||||||
|
|
||||||
|
let outstandingRequests = {};
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
export const resetStats = (): void => {
|
export const resetStats = (): void => {
|
||||||
stats = {};
|
stats = {};
|
||||||
|
outstandingRequests = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
|
@ -30,15 +33,22 @@ export const printStats = (): void => {
|
||||||
res.median = entries[Math.floor(entries.length / 2)];
|
res.median = entries[Math.floor(entries.length / 2)];
|
||||||
hostStats[hostname] = res;
|
hostStats[hostname] = res;
|
||||||
}
|
}
|
||||||
logger.debug({ hostStats }, 'Host request stats (milliseconds)');
|
logger.debug(
|
||||||
|
{ hostStats, outstandingRequests },
|
||||||
|
'Host request stats (milliseconds)'
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const instance = create({
|
export const instance = create({
|
||||||
options: {},
|
options: {},
|
||||||
handler: (options, next) => {
|
handler: (options, next) => {
|
||||||
|
const request = `${options.method} ${options.href}`;
|
||||||
|
logger.info(request);
|
||||||
|
outstandingRequests[request] = true;
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
const nextPromise = next(options);
|
const nextPromise = next(options);
|
||||||
nextPromise.on('response', () => {
|
nextPromise.on('response', () => {
|
||||||
|
delete outstandingRequests[request];
|
||||||
const elapsed = new Date().getTime() - start.getTime();
|
const elapsed = new Date().getTime() - start.getTime();
|
||||||
stats[options.hostname] = stats[options.hostname] || [];
|
stats[options.hostname] = stats[options.hostname] || [];
|
||||||
stats[options.hostname].push(elapsed);
|
stats[options.hostname].push(elapsed);
|
||||||
|
|
Loading…
Reference in a new issue