Skip to content

Commit

Permalink
concord-server: tone down websocket errors
Browse files Browse the repository at this point in the history
The actual stacktraces are not particularly useful, it is always just
Jetty stuff. Let us log such errors as WARN plus the user agent.
  • Loading branch information
ibodrov committed Apr 26, 2024
1 parent dca1686 commit 39203d1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public WebSocketListener(WebSocketChannelManager channelManager, UUID channelId,
this.channelManager = channelManager;
this.channelId = channelId;
this.agentId = agentId;
this.userAgent = userAgent;
this.userAgent = sanitize(userAgent);
}

@Override
Expand Down Expand Up @@ -82,6 +82,16 @@ public void onWebSocketConnect(Session session) {

@Override
public void onWebSocketError(Throwable cause) {
log.error("onWebSocketError ['{}'] -> error", channelId, cause);
log.warn("onWebSocketError ['{}', '{}'] -> error: {}", channelId, userAgent, cause.getMessage());
}

private static String sanitize(String log) {
if (log == null || log.isEmpty()) {
return log;
}
if (log.length() > 128) {
log = log.substring(0, 128) + "...cut";
}
return log.replace("\n", "\\n");
}
}

0 comments on commit 39203d1

Please sign in to comment.