Repository: camel
Updated Branches:
  refs/heads/master d49617ca4 -> 4e13eae10


CAMEL-9795: camel-zipkin - Reuse existing span for complex eips like multicast.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4e13eae1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4e13eae1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4e13eae1

Branch: refs/heads/master
Commit: 4e13eae10a6fcb30846e786bc76b78f3f1fcbfb8
Parents: d49617c
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Apr 5 09:21:03 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Apr 5 09:21:03 2016 +0200

----------------------------------------------------------------------
 .../org/apache/camel/zipkin/ZipkinTracer.java   | 79 ++++++++++----------
 1 file changed, 38 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4e13eae1/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinTracer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinTracer.java
 
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinTracer.java
index 98e7038..546ec51 100644
--- 
a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinTracer.java
+++ 
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinTracer.java
@@ -500,20 +500,17 @@ public class ZipkinTracer extends EventNotifierSupport 
implements RoutePolicy, R
         clientBinder.setCurrentSpan(null);
         serverBinder.setCurrentSpan(null);
 
-        if (log.isDebugEnabled()) {
-            String traceId = "<null>";
-            if (span != null) {
-                traceId = "" + span.getTrace_id();
-            }
-            String spanId = "<null>";
-            if (span != null) {
-                spanId = "" + span.getId();
-            }
-            String parentId = "<null>";
-            if (span != null) {
-                parentId = "" + span.getParent_id();
+        if (span != null && log.isDebugEnabled()) {
+            String traceId = "" + span.getTrace_id();
+            String spanId = "" + span.getId();
+            String parentId = span.getParent_id() != null ? "" + 
span.getParent_id() : null;
+            if (log.isDebugEnabled()) {
+                if (parentId != null) {
+                    log.debug(String.format("clientRequest [service=%s, 
traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, 
parentId));
+                } else {
+                    log.debug(String.format("clientRequest [service=%s, 
traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
+                }
             }
-            log.debug("clientRequest [service={}, traceId={}, spanId={}, 
parentId={}]", serviceName, traceId, spanId, parentId);
         }
     }
 
@@ -535,8 +532,14 @@ public class ZipkinTracer extends EventNotifierSupport 
implements RoutePolicy, R
             if (log.isDebugEnabled()) {
                 String traceId = "" + span.getTrace_id();
                 String spanId = "" + span.getId();
-                String parentId = "" + span.getParent_id();
-                log.debug("clientResponse[service={}, traceId={}, spanId={}, 
parentId={}]", serviceName, traceId, spanId, parentId);
+                String parentId = span.getParent_id() != null ? "" + 
span.getParent_id() : null;
+                if (log.isDebugEnabled()) {
+                    if (parentId != null) {
+                        log.debug(String.format("clientResponse[service=%s, 
traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, 
parentId));
+                    } else {
+                        log.debug(String.format("clientResponse[service=%s, 
traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
+                    }
+                }
             }
         }
     }
@@ -564,20 +567,17 @@ public class ZipkinTracer extends EventNotifierSupport 
implements RoutePolicy, R
         // and reset binder
         serverBinder.setCurrentSpan(null);
 
-        if (log.isDebugEnabled()) {
-            String traceId = "<null>";
-            if (span.getSpan() != null) {
-                traceId = "" + span.getSpan().getTrace_id();
-            }
-            String spanId = "<null>";
-            if (span.getSpan() != null) {
-                spanId = "" + span.getSpan().getId();
-            }
-            String parentId = "<null>";
-            if (span.getSpan() != null) {
-                parentId = "" + span.getSpan().getParent_id();
+        if (span != null && span.getSpan() != null && log.isDebugEnabled()) {
+            String traceId = "" + span.getSpan().getTrace_id();
+            String spanId = "" + span.getSpan().getId();
+            String parentId = span.getSpan().getParent_id() != null ? "" + 
span.getSpan().getParent_id() : null;
+            if (log.isDebugEnabled()) {
+                if (parentId != null) {
+                    log.debug(String.format("serverRequest [service=%s, 
traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, 
parentId));
+                } else {
+                    log.debug(String.format("serverRequest [service=%s, 
traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
+                }
             }
-            log.debug("serverRequest [service={}, traceId={}, spanId={}, 
parentId={}]", serviceName, traceId, spanId, parentId);
         }
 
         return span;
@@ -598,20 +598,17 @@ public class ZipkinTracer extends EventNotifierSupport 
implements RoutePolicy, R
             // and reset binder
             serverBinder.setCurrentSpan(null);
 
-            if (log.isDebugEnabled()) {
-                String traceId = "<null>";
-                if (span.getSpan() != null) {
-                    traceId = "" + span.getSpan().getTrace_id();
-                }
-                String spanId = "<null>";
-                if (span.getSpan() != null) {
-                    spanId = "" + span.getSpan().getId();
-                }
-                String parentId = "<null>";
-                if (span.getSpan() != null) {
-                    parentId = "" + span.getSpan().getParent_id();
+            if (span.getSpan() != null && log.isDebugEnabled()) {
+                String traceId = "" + span.getSpan().getTrace_id();
+                String spanId = "" + span.getSpan().getId();
+                String parentId = span.getSpan().getParent_id() != null ? "" + 
span.getSpan().getParent_id() : null;
+                if (log.isDebugEnabled()) {
+                    if (parentId != null) {
+                        log.debug(String.format("serverResponse[service=%s, 
traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, 
parentId));
+                    } else {
+                        log.debug(String.format("serverResponse[service=%s, 
traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
+                    }
                 }
-                log.debug("serverResponse[service={}, traceId={}, spanId={}, 
parentId={}]", serviceName, traceId, spanId, parentId);
             }
         }
     }

Reply via email to