Skip to content
Snippets Groups Projects
Unverified Commit 0ed2592e authored by syuilo's avatar syuilo
Browse files

Resolve #4453

parent 76cff982
No related branches found
No related tags found
No related merge requests found
import { performance } from 'perf_hooks';
import limiter from './limiter';
import { IUser } from '../../models/user';
import { IApp } from '../../models/app';
......@@ -71,6 +72,7 @@ export default async (endpoint: string, user: IUser, app: IApp, data: any, file?
}
// API invoking
const before = performance.now();
return await ep.exec(data, user, app, file).catch((e: Error) => {
if (e instanceof ApiError) {
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)`);
}
});
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment