cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cxf git commit: CXF-7247: Support tracing using latest Zipkin Brave 4.x release. Fixing parent scope propagation for wrapped calls (callables).
Date Fri, 02 Jun 2017 23:09:55 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8e77e5416 -> 70a6f989e


CXF-7247: Support tracing using latest Zipkin Brave 4.x release. Fixing parent scope propagation
for wrapped calls (callables).


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/70a6f989
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/70a6f989
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/70a6f989

Branch: refs/heads/master
Commit: 70a6f989e7062121a73ccdbc686dea4025d41f55
Parents: 8e77e54
Author: reta <drreta@gmail.com>
Authored: Fri Jun 2 19:09:33 2017 -0400
Committer: reta <drreta@gmail.com>
Committed: Fri Jun 2 19:09:33 2017 -0400

----------------------------------------------------------------------
 .../apache/cxf/tracing/brave/BraveTracerContext.java  | 14 ++++++++++++--
 .../systest/jaxrs/tracing/brave/BraveTracingTest.java |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/70a6f989/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
index 5b3e9cb..96160f5 100644
--- a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
@@ -54,7 +54,7 @@ public class BraveTracerContext implements TracerContext {
     public <T> T continueSpan(final Traceable<T> traceable) throws Exception
{
         SpanInScope scope = null;
         
-        if (tracer.currentSpan() != null && continuationSpan != null) {
+        if (tracer.currentSpan() == null && continuationSpan != null) {
             scope = tracer.withSpanInScope(continuationSpan);
         }
 
@@ -76,8 +76,10 @@ public class BraveTracerContext implements TracerContext {
             }
         };
 
+        // Carry over parent from the current thread
+        final Span parent = tracer.currentSpan();
         return () -> {
-            try (TraceScope span = startSpan(description)) {
+            try (TraceScope span = newOrChildSpan(description, parent)) {
                 return callable.call();
             } 
         };
@@ -98,4 +100,12 @@ public class BraveTracerContext implements TracerContext {
             current.annotate(message);
         }
     }
+    
+    private TraceScope newOrChildSpan(final String description, final Span parent) {
+        if (parent == null) { 
+            return new TraceScope(brave, tracer.newTrace().name(description).start());
+        } else {
+            return new TraceScope(brave, tracer.newChild(parent.context()).name(description).start());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/70a6f989/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java
index 315a365..170ff13 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java
@@ -196,6 +196,9 @@ public class BraveTracingTest extends AbstractBusClientServerTestBase
{
         assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
         assertThat(TestSpanReporter.getAllSpans().get(1).name, equalTo("get /bookstore/books/async"));
         assertThat(TestSpanReporter.getAllSpans().get(0).name, equalTo("processing books"));
+        assertThat(TestSpanReporter.getAllSpans().get(0).parentId, not(nullValue()));
+        assertThat(TestSpanReporter.getAllSpans().get(0).parentId, 
+            equalTo(TestSpanReporter.getAllSpans().get(1).id));
 
         assertThatTraceIsPresent(r, spanId);
     }


Mime
View raw message