Wraped debug logs with conditional
This commit is contained in:
@@ -84,11 +84,13 @@ public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
|
||||
private void logCurrentStateOfHysrixPlugins(HystrixEventNotifier eventNotifier,
|
||||
HystrixMetricsPublisher metricsPublisher,
|
||||
HystrixPropertiesStrategy propertiesStrategy) {
|
||||
log.debug("Current Hystrix plugins configuration is [" + "concurrencyStrategy ["
|
||||
+ this.delegate + "]," + "eventNotifier [" + eventNotifier + "],"
|
||||
+ "metricPublisher [" + metricsPublisher + "]," + "propertiesStrategy ["
|
||||
+ propertiesStrategy + "]," + "]");
|
||||
log.debug("Registering Sleuth Hystrix Concurrency Strategy.");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Current Hystrix plugins configuration is [" + "concurrencyStrategy ["
|
||||
+ this.delegate + "]," + "eventNotifier [" + eventNotifier + "],"
|
||||
+ "metricPublisher [" + metricsPublisher + "]," + "propertiesStrategy ["
|
||||
+ propertiesStrategy + "]," + "]");
|
||||
log.debug("Registering Sleuth Hystrix Concurrency Strategy.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -66,8 +66,10 @@ class HttpServletRequestExtractor implements SpanExtractor<HttpServletRequest> {
|
||||
private long spanId(HttpServletRequest carrier, long traceId) {
|
||||
String spanId = carrier.getHeader(Span.SPAN_ID_NAME);
|
||||
if (spanId == null) {
|
||||
log.debug("Request is missing a span id but it has a trace id. We'll assume that this is "
|
||||
+ "a root span with span id equal to trace id");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Request is missing a span id but it has a trace id. We'll assume that this is "
|
||||
+ "a root span with span id equal to trace id");
|
||||
}
|
||||
return traceId;
|
||||
} else {
|
||||
return Span.hexToId(spanId);
|
||||
|
||||
@@ -315,7 +315,9 @@ public class TraceFilter extends GenericFilterBean {
|
||||
}
|
||||
spanFromRequest.logEvent(Span.SERVER_RECV);
|
||||
request.setAttribute(TRACE_REQUEST_ATTR, spanFromRequest);
|
||||
log.debug("No parent span present - creating a new span");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No parent span present - creating a new span");
|
||||
}
|
||||
}
|
||||
return spanFromRequest;
|
||||
}
|
||||
|
||||
@@ -62,11 +62,15 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler) throws Exception {
|
||||
if (isErrorControllerRelated(request)) {
|
||||
log.debug("Skipping creation of a span for error controller processing");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Skipping creation of a span for error controller processing");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (isSpanContinued(request)) {
|
||||
log.debug("Skipping creation of a span since the span is continued");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Skipping creation of a span since the span is continued");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
String spanName = spanName(handler);
|
||||
@@ -131,11 +135,15 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) throws Exception {
|
||||
if (isErrorControllerRelated(request)) {
|
||||
log.debug("Skipping closing of a span for error controller processing");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Skipping closing of a span for error controller processing");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isSpanContinued(request)) {
|
||||
log.debug("Skipping closing of a span since it's been continued");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Skipping closing of a span since it's been continued");
|
||||
}
|
||||
return;
|
||||
}
|
||||
Span span = getSpanFromAttribute(request);
|
||||
|
||||
@@ -100,8 +100,9 @@ public class TraceWebAspect {
|
||||
public Object wrapWithCorrelationId(ProceedingJoinPoint pjp) throws Throwable {
|
||||
Callable<Object> callable = (Callable<Object>) pjp.proceed();
|
||||
if (this.tracer.isTracing()) {
|
||||
log.debug("Wrapping callable with span ["
|
||||
+ this.tracer.getCurrentSpan() + "]");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Wrapping callable with span [" + this.tracer.getCurrentSpan() + "]");
|
||||
}
|
||||
return new TraceContinuingCallable<>(this.tracer, this.spanNamer, callable);
|
||||
}
|
||||
else {
|
||||
@@ -114,8 +115,10 @@ public class TraceWebAspect {
|
||||
final WebAsyncTask<?> webAsyncTask = (WebAsyncTask<?>) pjp.proceed();
|
||||
if (this.tracer.isTracing()) {
|
||||
try {
|
||||
log.debug("Wrapping callable with span ["
|
||||
+ this.tracer.getCurrentSpan() + "]");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Wrapping callable with span [" + this.tracer.getCurrentSpan()
|
||||
+ "]");
|
||||
}
|
||||
Field callableField = WebAsyncTask.class.getDeclaredField("callable");
|
||||
callableField.setAccessible(true);
|
||||
callableField.set(webAsyncTask, new TraceContinuingCallable<>(this.tracer,
|
||||
|
||||
@@ -92,7 +92,9 @@ final class TraceFeignClient implements Client {
|
||||
private void closeSpan() {
|
||||
Span span = getTracer().getCurrentSpan();
|
||||
if (span != null) {
|
||||
log.debug("Closing Feign span " + span);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Closing Feign span " + span);
|
||||
}
|
||||
getTracer().close(span);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +102,9 @@ final class TraceFeignClient implements Client {
|
||||
private void logCr() {
|
||||
Span span = getTracer().getCurrentSpan();
|
||||
if (span != null) {
|
||||
log.debug("Closing Feign span and logging CR" + span);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Closing Feign span and logging CR" + span);
|
||||
}
|
||||
span.logEvent(Span.CLIENT_RECV);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +113,9 @@ final class TraceFeignClient implements Client {
|
||||
Span span = getTracer().getCurrentSpan();
|
||||
if (span != null) {
|
||||
String message = e.getMessage() != null ? e.getMessage() : e.toString();
|
||||
log.debug("Appending exception [" + message + "] to span " + span);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Appending exception [" + message + "] to span " + span);
|
||||
}
|
||||
getTracer().addTag("error", message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,11 @@ final class ConvertToZipkinSpanList {
|
||||
zipkinSpan.traceId(span.getTraceId());
|
||||
if (span.getParents().size() > 0) {
|
||||
if (span.getParents().size() > 1) {
|
||||
log.debug("zipkin doesn't support spans with multiple parents. Omitting "
|
||||
+ "other parents for " + span);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"zipkin doesn't support spans with multiple parents. Omitting "
|
||||
+ "other parents for " + span);
|
||||
}
|
||||
}
|
||||
zipkinSpan.parentId(span.getParents().get(0));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,9 @@ public final class HttpZipkinSpanReporter
|
||||
byte[] json = Codec.JSON.writeSpans(drained);
|
||||
// NOTE: https://github.com/openzipkin/zipkin-java/issues/66 will throw instead of return null.
|
||||
if (json == null) {
|
||||
log.debug("failed to encode spans, dropping them: " + drained);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("failed to encode spans, dropping them: " + drained);
|
||||
}
|
||||
this.spanMetricReporter.incrementDroppedSpans(drained.size());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user