Skip to content

Commit

Permalink
[papi] log ctx time if request took too much time (gitpod-io#19343)
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh authored Jan 23, 2024
1 parent eb2c3de commit f869669
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/server/src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ export class API {
grpcServerHandled.labels(grpc_service, grpc_method, grpc_type, grpc_code).inc();
stopTimer({ grpc_code });
log.debug("public api: done", { grpc_code });
// If the request took too long, log it
const ctxTime = requestContext.startTime ? performance.now() - requestContext.startTime : 0;
if (grpc_type === "unary" && ctxTime > 5000) {
log.warn("public api: request took too long", { ctxTime, grpc_code });
}
};
const handleError = (reason: unknown) => {
const err = self.apiConverter.toError(reason);
Expand Down

0 comments on commit f869669

Please sign in to comment.