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

Ensure logs are prefixed with channel information when possible #2529

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 @@ -28,6 +28,8 @@

import java.net.SocketAddress;

import static reactor.netty.ReactorNetty.format;

/**
* Base {@link ChannelHandler} for collecting metrics on protocol level.
*
Expand Down Expand Up @@ -55,7 +57,7 @@ public void channelActive(ChannelHandlerContext ctx) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -71,7 +73,7 @@ public void channelInactive(ChannelHandlerContext ctx) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down Expand Up @@ -116,7 +118,7 @@ else if (msg instanceof DatagramPacket) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down Expand Up @@ -144,7 +146,7 @@ else if (msg instanceof DatagramPacket) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -160,7 +162,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down
Expand Up @@ -389,7 +389,7 @@ else if (alloc instanceof UnpooledByteBufAllocator) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(channel, "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down
Expand Up @@ -33,6 +33,8 @@
import java.time.Duration;
import java.util.function.Function;

import static reactor.netty.ReactorNetty.format;

/**
* @author Violeta Georgieva
* @since 1.0.8
Expand Down Expand Up @@ -95,7 +97,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -104,7 +106,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -130,7 +132,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -144,7 +146,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down
Expand Up @@ -33,6 +33,8 @@
import java.time.Duration;
import java.util.function.Function;

import static reactor.netty.ReactorNetty.format;

/**
* @author Violeta Georgieva
* @since 1.0.8
Expand Down Expand Up @@ -74,7 +76,7 @@ public void channelActive(ChannelHandlerContext ctx) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -90,7 +92,7 @@ public void channelInactive(ChannelHandlerContext ctx) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down Expand Up @@ -123,7 +125,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -140,7 +142,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -153,7 +155,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down Expand Up @@ -194,7 +196,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand All @@ -214,7 +216,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
catch (RuntimeException e) {
if (log.isWarnEnabled()) {
log.warn("Exception caught while recording metrics.", e);
log.warn(format(ctx.channel(), "Exception caught while recording metrics."), e);
}
// Allow request-response exchange to continue, unaffected by metrics problem
}
Expand Down