Skip to content

Commit

Permalink
Reduce log spam (#25)
Browse files Browse the repository at this point in the history
* Reduce log spam

- Emit spammy status logging at DEBUG
- Mark spammy error logging with a "spammy" flag that can be used to filter
  out logs

* fixup! Reduce log spam
  • Loading branch information
nbrahms authored Feb 27, 2024
1 parent cab2a6a commit 8fc5a61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class JsonRpcServer {
ws.on("close", () => {
onChannelClose(channelId);
this.#channels.delete(channelId);
this.#logger.info({ channelId }, "Channel closed");
this.#logger.debug({ channelId }, "Channel closed");
});

this.#channels.set(channelId, channel);
Expand Down Expand Up @@ -193,7 +193,7 @@ export class JsonRpcServer {
return response;
} catch (error) {
this.#logger.error(
{ requestId, channelId, method, error },
{ requestId, channelId, method, error, spammy: true },
"RPC response"
);
throw error;
Expand Down
9 changes: 5 additions & 4 deletions server/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ export const httpProxyApp = (
} else {
res.status(response.status).send(response.data);
}
} catch (e: any) {
logger.error({ error: e }, "error handling request");
} catch (error: any) {
logger.error({ error, spammy: true }, "Error handling request");
if (
// Timeout waiting for response on the the websocket channel
e.message === "Request timeout" ||
error.message === "Request timeout" ||
// Timeout in axios client from proxy to target service (e.g. Kubernetes API server) - "timeout of 1000ms exceeded"
(e.message.startsWith("timeout") && e.message.endsWith("exceeded"))
(error.message.startsWith("timeout") &&
error.message.endsWith("exceeded"))
) {
res.sendStatus(504);
} else {
Expand Down

0 comments on commit 8fc5a61

Please sign in to comment.