Skip to content

Commit f869669

Browse files
authored
[papi] log ctx time if request took too much time (#19343)
1 parent eb2c3de commit f869669

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/server/src/api/server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ export class API {
215215
grpcServerHandled.labels(grpc_service, grpc_method, grpc_type, grpc_code).inc();
216216
stopTimer({ grpc_code });
217217
log.debug("public api: done", { grpc_code });
218+
// If the request took too long, log it
219+
const ctxTime = requestContext.startTime ? performance.now() - requestContext.startTime : 0;
220+
if (grpc_type === "unary" && ctxTime > 5000) {
221+
log.warn("public api: request took too long", { ctxTime, grpc_code });
222+
}
218223
};
219224
const handleError = (reason: unknown) => {
220225
const err = self.apiConverter.toError(reason);

0 commit comments

Comments
 (0)