Resolve #4453
This commit is contained in:
parent
76cff98220
commit
0ed2592e41
1 changed files with 8 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { performance } from 'perf_hooks';
|
||||||
import limiter from './limiter';
|
import limiter from './limiter';
|
||||||
import { IUser } from '../../models/user';
|
import { IUser } from '../../models/user';
|
||||||
import { IApp } from '../../models/app';
|
import { IApp } from '../../models/app';
|
||||||
|
@ -71,6 +72,7 @@ export default async (endpoint: string, user: IUser, app: IApp, data: any, file?
|
||||||
}
|
}
|
||||||
|
|
||||||
// API invoking
|
// API invoking
|
||||||
|
const before = performance.now();
|
||||||
return await ep.exec(data, user, app, file).catch((e: Error) => {
|
return await ep.exec(data, user, app, file).catch((e: Error) => {
|
||||||
if (e instanceof ApiError) {
|
if (e instanceof ApiError) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -88,5 +90,11 @@ export default async (endpoint: string, user: IUser, app: IApp, data: any, file?
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
const after = performance.now();
|
||||||
|
const time = after - before;
|
||||||
|
if (time > 1000) {
|
||||||
|
apiLogger.warn(`SLOW API CALL DETECTED: ${ep.name} (${time}ms)`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue