protected void logErrorWithTracing(String msg, Throwable ex, HttpProcessingState state) { Deque<Span> distributedTraceStackToLink = null; Map<String, String> mdcContextMapToLink = null; if (state != null) { distributedTraceStackToLink = state.getDistributedTraceStack(); mdcContextMapToLink = state.getLoggerMdcContextMap(); } logErrorWithTracing(msg, ex, distributedTraceStackToLink, mdcContextMapToLink); }
protected void logErrorWithTracing(String msg, Throwable ex, HttpProcessingState state) { Deque<Span> distributedTraceStackToLink = null; Map<String, String> mdcContextMapToLink = null; if (state != null) { distributedTraceStackToLink = state.getDistributedTraceStack(); mdcContextMapToLink = state.getLoggerMdcContextMap(); } logErrorWithTracing(msg, ex, distributedTraceStackToLink, mdcContextMapToLink); }
@Test public void logErrorWithTracing_using_HttpProcessingState_gracefully_handles_when_state_is_null() { // given String msg = UUID.randomUUID().toString(); Throwable exMock = mock(Throwable.class); ChannelPipelineFinalizerHandler handlerSpy = spy(handler); // when handlerSpy.logErrorWithTracing(msg, exMock, (HttpProcessingState)null); // then verify(handlerSpy).logErrorWithTracing(msg, exMock, null, null); }
@Test public void logErrorWithTracing_using_ChannelHandlerContext_gracefully_handles_when_ctx_is_null() { // given String msg = UUID.randomUUID().toString(); Throwable exMock = mock(Throwable.class); ChannelPipelineFinalizerHandler handlerSpy = spy(handler); // when handlerSpy.logErrorWithTracing(msg, exMock, (ChannelHandlerContext)null); // then verify(handlerSpy).logErrorWithTracing(msg, exMock, null, null); }
@SuppressWarnings("SameParameterValue") protected void logErrorWithTracing(String msg, Throwable ex, ChannelHandlerContext ctx) { Pair<Deque<Span>, Map<String, String>> tracingState = AsyncNettyHelper.extractTracingAndMdcInfoFromChannelHandlerContext(ctx); Deque<Span> distributedTraceStackToLink = null; Map<String, String> mdcContextMapToLink = null; if (tracingState != null) { distributedTraceStackToLink = tracingState.getLeft(); mdcContextMapToLink = tracingState.getRight(); } logErrorWithTracing(msg, ex, distributedTraceStackToLink, mdcContextMapToLink); }
@SuppressWarnings("SameParameterValue") protected void logErrorWithTracing(String msg, Throwable ex, ChannelHandlerContext ctx) { Pair<Deque<Span>, Map<String, String>> tracingState = AsyncNettyHelper.extractTracingAndMdcInfoFromChannelHandlerContext(ctx); Deque<Span> distributedTraceStackToLink = null; Map<String, String> mdcContextMapToLink = null; if (tracingState != null) { distributedTraceStackToLink = tracingState.getLeft(); mdcContextMapToLink = tracingState.getRight(); } logErrorWithTracing(msg, ex, distributedTraceStackToLink, mdcContextMapToLink); }
String errorMsg = "Discovered a request that snuck through without a response being sent. This should not " + "be possible and indicates a major problem in the channel pipeline."; logErrorWithTracing(errorMsg, new Exception("Wrapper exception", cause), state); logErrorWithTracing( "Received an error in ChannelPipelineFinalizerHandler after response sending was started, but " + "before it finished. Closing the channel. unexpected_error=" + cause.toString(),
String errorMsg = "Discovered a request that snuck through without a response being sent. This should not " + "be possible and indicates a major problem in the channel pipeline."; logErrorWithTracing(errorMsg, new Exception("Wrapper exception", cause), state); logErrorWithTracing( "Received an error in ChannelPipelineFinalizerHandler after response sending was started, but " + "before it finished. Closing the channel. unexpected_error=" + cause.toString(),
logErrorWithTracing( "An unexpected error occurred while trying to finalize metrics. " + "This exception will be swallowed.", t, state
logErrorWithTracing( "An unexpected error occurred while trying to finalize metrics. " + "This exception will be swallowed.", t, state
logErrorWithTracing( "An unexpected error occurred while trying to finalize distributed tracing. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to finalize access logging. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to release request resources. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to release ProxyRouter state resources. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred during ChannelPipelineFinalizerHandler.doChannelInactive() - this " + "should not happen and indicates a bug that needs to be fixed in Riposte.", t, ctx
logErrorWithTracing( "An unexpected error occurred while trying to finalize distributed tracing. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to finalize access logging. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to release request resources. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred while trying to release ProxyRouter state resources. " + "This exception will be swallowed.", t, httpState logErrorWithTracing( "An unexpected error occurred during ChannelPipelineFinalizerHandler.doChannelInactive() - this " + "should not happen and indicates a bug that needs to be fixed in Riposte.", t, ctx