Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug logs for http2 stream errors #4515

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.netty.handler.codec.http2.Http2ConnectionEncoder;
import io.netty.handler.codec.http2.Http2ConnectionHandler;
import io.netty.handler.codec.http2.Http2Exception;
import io.netty.handler.codec.http2.Http2Exception.StreamException;
import io.netty.handler.codec.http2.Http2Settings;
import io.netty.handler.codec.http2.Http2Stream.State;
import io.netty.handler.codec.http2.Http2StreamVisitor;
Expand Down Expand Up @@ -111,13 +112,24 @@ protected final void onConnectionError(ChannelHandlerContext ctx, boolean outbou

handlingConnectionError = true;
if (Exceptions.isExpected(cause) || isGoAwaySentException(cause, connection())) {
// Ignore silently.
if (logger.isDebugEnabled()) {
logger.debug("{} HTTP/2 connection error:", ctx.channel(), cause);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (logger.isDebugEnabled()) {
logger.debug("{} HTTP/2 connection error:", ctx.channel(), cause);
}
logger.debug("{} HTTP/2 connection error:", ctx.channel(), cause);

We use isDebugEnabled when it takes cost to create instances that are logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought that there would be some cost if a throwable was passed in.
Went through the code and verified at least logback terminates early 👍

} else {
logger.warn("{} HTTP/2 connection error:", ctx.channel(), cause);
}
super.onConnectionError(ctx, outbound, cause, filterHttp2Exception(cause, http2Ex));
}

@Override
protected void onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause,
StreamException http2Ex) {
if (logger.isDebugEnabled()) {
logger.debug("{} HTTP/2 stream error:", ctx.channel(), cause);
}
super.onStreamError(ctx, outbound, cause, http2Ex);
}

private static Http2Exception filterHttp2Exception(Throwable cause, @Nullable Http2Exception http2Ex) {
if (http2Ex != null) {
return http2Ex;
Expand Down