From 0f7b14d76c423b0f00d4ab29f9a1b1bd65301e1b Mon Sep 17 00:00:00 2001 From: Nathan Brahms Date: Tue, 27 Feb 2024 14:55:30 -0800 Subject: [PATCH 1/2] 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 --- server/index.ts | 2 +- server/proxy.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/index.ts b/server/index.ts index f412389..47aec7c 100644 --- a/server/index.ts +++ b/server/index.ts @@ -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); diff --git a/server/proxy.ts b/server/proxy.ts index 61dafec..eceb17c 100644 --- a/server/proxy.ts +++ b/server/proxy.ts @@ -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 { From 8682d8e9eb4b451f13942cafad17a5a904a056cd Mon Sep 17 00:00:00 2001 From: Nathan Brahms Date: Tue, 27 Feb 2024 15:44:32 -0800 Subject: [PATCH 2/2] fixup! Reduce log spam --- server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/index.ts b/server/index.ts index 47aec7c..b89522d 100644 --- a/server/index.ts +++ b/server/index.ts @@ -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;