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

Check for log level #2528

Merged
merged 1 commit into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,7 +54,9 @@ public void channelActive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionOpened(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -68,7 +70,9 @@ public void channelInactive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionClosed(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down Expand Up @@ -111,7 +115,9 @@ else if (msg instanceof DatagramPacket) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -137,7 +143,9 @@ else if (msg instanceof DatagramPacket) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -151,7 +159,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
recordException(ctx, remoteAddress != null ? remoteAddress : ctx.channel().remoteAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand Down
Expand Up @@ -337,8 +337,10 @@ protected static final class PoolFactory<T extends Connection> {
Double.parseDouble(System.getProperty(ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE, "0"));
if (getPermitsSamplingRate > 1d) {
DEFAULT_POOL_GET_PERMITS_SAMPLING_RATE = 0;
log.warn("Invalid configuration [" + ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE + "=" + getPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy in not enabled.");
if (log.isWarnEnabled()) {
log.warn("Invalid configuration [" + ReactorNetty.POOL_GET_PERMITS_SAMPLING_RATE + "=" + getPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy in not enabled.");
}
}
else {
DEFAULT_POOL_GET_PERMITS_SAMPLING_RATE = getPermitsSamplingRate;
Expand All @@ -351,8 +353,10 @@ protected static final class PoolFactory<T extends Connection> {
Double.parseDouble(System.getProperty(ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE, "0"));
if (returnPermitsSamplingRate > 1d) {
DEFAULT_POOL_RETURN_PERMITS_SAMPLING_RATE = 0;
log.warn("Invalid configuration [" + ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE + "=" + returnPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy is enabled.");
if (log.isWarnEnabled()) {
log.warn("Invalid configuration [" + ReactorNetty.POOL_RETURN_PERMITS_SAMPLING_RATE + "=" + returnPermitsSamplingRate +
"], the value must be between 0d and 1d (percentage). SamplingAllocationStrategy is enabled.");
}
}
else {
DEFAULT_POOL_RETURN_PERMITS_SAMPLING_RATE = returnPermitsSamplingRate;
Expand Down
Expand Up @@ -127,7 +127,9 @@ void record(long resolveTimeStart, String status, SocketAddress remoteAddress) {
status);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down
Expand Up @@ -400,7 +400,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
.eventLoop()
.schedule(enableAutoReadTask, 1, TimeUnit.SECONDS)
.addListener(future -> {
if (!future.isSuccess()) {
if (!future.isSuccess() && log.isDebugEnabled()) {
log.debug(format(ctx.channel(), "Cannot enable auto-read"), future.cause());
}
});
Expand All @@ -419,7 +419,9 @@ void enableAutoReadTask(Channel channel) {

static void forceClose(Channel child, Throwable t) {
child.unsafe().closeForcibly();
log.warn(format(child, "Failed to register an accepted channel: {}"), child, t);
if (log.isWarnEnabled()) {
log.warn(format(child, "Failed to register an accepted channel: {}"), child, t);
}
}
}

Expand Down
Expand Up @@ -388,7 +388,9 @@ else if (alloc instanceof UnpooledByteBufAllocator) {
MicrometerEventLoopMeterRegistrar.INSTANCE.registerMetrics(channel.eventLoop());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down
Expand Up @@ -169,12 +169,16 @@ static void setChannelOptions(Channel channel, Map<ChannelOption<?>, ?> options,
}
try {
if (!channel.config().setOption((ChannelOption<Object>) e.getKey(), e.getValue())) {
log.warn(format(channel, "Unknown channel option '{}' for channel '{}'"), e.getKey(), channel);
if (log.isWarnEnabled()) {
log.warn(format(channel, "Unknown channel option '{}' for channel '{}'"), e.getKey(), channel);
}
}
}
catch (Throwable t) {
log.warn(format(channel, "Failed to set channel option '{}' with value '{}' for channel '{}'"),
e.getKey(), e.getValue(), channel, t);
if (log.isWarnEnabled()) {
log.warn(format(channel, "Failed to set channel option '{}' with value '{}' for channel '{}'"),
e.getKey(), e.getValue(), channel, t);
}
}
}
}
Expand Down
Expand Up @@ -120,8 +120,10 @@ public NettyOutbound send(Publisher<? extends ByteBuf> source) {
return Mono.error(e);
}
if (HttpUtil.getContentLength(outboundHttpMessage(), -1) == 0) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(msg));
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(msg));
}
msg.release();
return FutureMono.from(channel().writeAndFlush(newFullBodyMessage(Unpooled.EMPTY_BUFFER)));
}
Expand Down Expand Up @@ -154,8 +156,10 @@ public NettyOutbound sendObject(Object message) {
throw e;
}
if (HttpUtil.getContentLength(outboundHttpMessage(), -1) == 0) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(b));
if (log.isDebugEnabled()) {
log.debug(format(channel(), "Dropped HTTP content, " +
"since response has Content-Length: 0 {}"), toPrettyHexDump(b));
}
b.release();
return channel().writeAndFlush(newFullBodyMessage(Unpooled.EMPTY_BUFFER));
}
Expand Down
Expand Up @@ -94,14 +94,18 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
recordWrite(address);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
});
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
//"FutureReturnValueIgnored" this is deliberate
Expand All @@ -125,7 +129,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
ctx.fireChannelRead(msg);
Expand All @@ -137,7 +143,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
recordException(ctx);
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
ctx.fireExceptionCaught(cause);
Expand Down
Expand Up @@ -73,7 +73,9 @@ public void channelActive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionOpened(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -87,7 +89,9 @@ public void channelInactive(ChannelHandlerContext ctx) {
recorder().recordServerConnectionClosed(ctx.channel().localAddress());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand Down Expand Up @@ -118,7 +122,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
ops.method().name(), ops.status().codeAsText().toString());
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
// ops.hostAddress() == null when request decoding failed, in this case
Expand All @@ -133,7 +139,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
}
Expand All @@ -144,7 +152,9 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
finally {
Expand Down Expand Up @@ -183,7 +193,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand All @@ -201,7 +213,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
}
catch (RuntimeException e) {
log.warn("Exception caught while recording metrics.", e);
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}

Expand Down
Expand Up @@ -123,7 +123,7 @@ final class WebsocketServerOperations extends HttpServerOperations
// This change is needed after the Netty change https://github.com/netty/netty/pull/11966
channel.read();
}
else {
else if (log.isDebugEnabled()) {
log.debug(format(channel, "Cannot bind WebsocketServerOperations after the handshake."));
}
});
Expand Down