summaryrefslogtreecommitdiff
path: root/src/server/api
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-03-08 20:07:29 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-03-08 20:07:29 +0900
commit0ed2592e41cb3b098ba34477e17433fe8f644b62 (patch)
tree564ee3eff28850b9c33fdc6913e4db3f268a0e1b /src/server/api
parentFix bug (diff)
downloadsharkey-0ed2592e41cb3b098ba34477e17433fe8f644b62.tar.gz
sharkey-0ed2592e41cb3b098ba34477e17433fe8f644b62.tar.bz2
sharkey-0ed2592e41cb3b098ba34477e17433fe8f644b62.zip
Resolve #4453
Diffstat (limited to 'src/server/api')
-rw-r--r--src/server/api/call.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/server/api/call.ts b/src/server/api/call.ts
index dac57b8f75..89a44b3c65 100644
--- a/src/server/api/call.ts
+++ b/src/server/api/call.ts
@@ -1,3 +1,4 @@
+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)`);
+ }
});
};