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-6360: Integration with Apache HTrace. Adding documentation. Minor impromevents to span descriptions.
Date Sun, 13 Sep 2015 20:50:07 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 1e6f12f65 -> 58d40a843


CXF-6360: Integration with Apache HTrace. Adding documentation. Minor impromevents to span
descriptions.


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

Branch: refs/heads/master
Commit: 58d40a843e50f7c581a9cc2373b431bf4a3f9780
Parents: 1e6f12f
Author: reta <drreta@gmail.com>
Authored: Sun Sep 13 16:49:21 2015 -0400
Committer: reta <drreta@gmail.com>
Committed: Sun Sep 13 16:49:21 2015 -0400

----------------------------------------------------------------------
 .../tracing/htrace/AbstractHTraceProvider.java  |  6 ++--
 .../tracing/htrace/HTraceStartInterceptor.java  |  3 +-
 .../htrace/jaxrs/HTraceClientProvider.java      |  3 +-
 .../tracing/htrace/jaxrs/HTraceProvider.java    |  3 +-
 .../cxf/tracing/AbstractTracingProvider.java    |  8 +++++
 .../org/apache/cxf/tracing/TracerContext.java   | 35 ++++++++++++++++++++
 .../jaxrs/tracing/htrace/HTraceTracingTest.java | 13 ++++----
 7 files changed, 59 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
index 380d97b..15e459c 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
@@ -46,7 +46,7 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
     }
 
     @SuppressWarnings("unchecked")
-    protected TraceScope startTraceSpan(final Map<String, List<String>> requestHeaders,
String path) {
+    protected TraceScope startTraceSpan(final Map<String, List<String>> requestHeaders,
String path, String method) {
         
         // Try to extract the Trace Id value from the request header
         final long traceId = getFirstValueOrDefault(requestHeaders, getTraceIdHeader(), 
@@ -58,9 +58,9 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider
{
         
         TraceScope traceScope = null;
         if (traceId == Tracer.DONT_TRACE.traceId || spanId == Tracer.DONT_TRACE.spanId) {
-            traceScope = Trace.startSpan(path, (Sampler< TraceInfo >)sampler);
+            traceScope = Trace.startSpan(buildSpanDescription(path, method), (Sampler<
TraceInfo >)sampler);
         } else {
-            traceScope = Trace.startSpan(path, new MilliSpan
+            traceScope = Trace.startSpan(buildSpanDescription(path, method), new MilliSpan
                 .Builder()
                 .spanId(spanId)
                 .traceId(traceId)

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceStartInterceptor.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceStartInterceptor.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceStartInterceptor.java
index cce392d..2cefbc5 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceStartInterceptor.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceStartInterceptor.java
@@ -35,7 +35,8 @@ public class HTraceStartInterceptor extends AbstractHTraceInterceptor {
     @Override
     public void handleMessage(Message message) throws Fault {
         Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));

-        TraceScope scope = super.startTraceSpan(headers, (String)message.get(Message.REQUEST_URI));
+        TraceScope scope = super.startTraceSpan(headers, (String)message.get(Message.REQUEST_URI),

+            (String)message.get(Message.HTTP_REQUEST_METHOD));
         message.getExchange().put(TRACE_SPAN, scope);
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceClientProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceClientProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceClientProvider.java
index 313cef3..fc88ec8 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceClientProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceClientProvider.java
@@ -54,7 +54,8 @@ public class HTraceClientProvider extends AbstractTracingProvider
         Span span = Trace.currentSpan();
         
         if (span == null) {
-            final TraceScope scope = Trace.startSpan(requestContext.getUri().toString(),
sampler);
+            final TraceScope scope = Trace.startSpan(buildSpanDescription(requestContext.getUri().toString(),

+                requestContext.getMethod()), sampler);
             span = scope.getSpan();
             
             if (span != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
index 9225220..d420c56 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/jaxrs/HTraceProvider.java
@@ -51,7 +51,8 @@ public class HTraceProvider extends AbstractHTraceProvider
     @Override
     public void filter(final ContainerRequestContext requestContext) throws IOException {
         TraceScope scope = super.startTraceSpan(requestContext.getHeaders(), 
-                                                requestContext.getUriInfo().getPath());
+                                                requestContext.getUriInfo().getPath(),
+                                                requestContext.getMethod());
         
         if (scope != null) {
             requestContext.setProperty(TRACE_SPAN, scope);

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/rt/management/src/main/java/org/apache/cxf/tracing/AbstractTracingProvider.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/tracing/AbstractTracingProvider.java
b/rt/management/src/main/java/org/apache/cxf/tracing/AbstractTracingProvider.java
index 71263bf..5c696d8 100644
--- a/rt/management/src/main/java/org/apache/cxf/tracing/AbstractTracingProvider.java
+++ b/rt/management/src/main/java/org/apache/cxf/tracing/AbstractTracingProvider.java
@@ -50,4 +50,12 @@ public abstract class AbstractTracingProvider {
         
         return fallback;
     }
+    
+    protected String buildSpanDescription(final String path, final String method) {
+        if (StringUtils.isEmpty(method)) {
+            return path;
+        } else {
+            return method + " " + path;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java b/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
index 325527c..36d027d 100644
--- a/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
+++ b/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
@@ -21,13 +21,48 @@ package org.apache.cxf.tracing;
 import java.util.concurrent.Callable;
 
 public interface TracerContext {
+    /**
+     * Picks up an currently detached span from another thread. This method is intended
+     * to be used in the context of JAX-RS asynchronous invocations, where request and 
+     * response are effectively executed by different threads.
+     * @param traceable traceable implementation to be executed
+     * @return the result of the execution 
+     * @throws Exception any exception being thrown by the traceable implementation 
+     */
     <T> T continueSpan(final Traceable<T> traceable) throws Exception;
     
+    /**
+     * Starts a new span in the current thread.
+     * @param desription span description
+     * @return span instance object
+     */
     <T> T startSpan(final String desription);
+    
+    /**
+     * Wraps the traceable into a new span, preserving the current span as a parent.
+     * @param desription span description
+     * @param traceable  traceable implementation to be wrapped
+     * @return callable to be executed (in current thread or any other thread pool)
+     */
     <T> Callable<T> wrap(final String desription, final Traceable<T> traceable);
     
+    /**
+     * Adds a key/value pair to the currently active span.
+     * @param key key to add
+     * @param value value to add
+     */
     void annotate(byte[] key, byte[] value);
+    
+    /**
+     * Adds a key/value pair to the currently active span.
+     * @param key key to add
+     * @param value value to add
+     */
     void annotate(String key, String value);
     
+    /**
+     * Adds a timeline to the currently active span.
+     * @param message timeline message
+     */
     void timeline(String message);
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/58d40a84/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
index 75efad5..48bd0cc 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
@@ -107,7 +107,7 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
         assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
-        assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("bookstore/books"));
+        assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("GET bookstore/books"));
         
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_TRACE_ID),
equalTo("10"));
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),
equalTo("20"));
@@ -122,7 +122,7 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         assertEquals(Status.OK.getStatusCode(), r.getStatus());
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(1));
-        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("bookstore/book/1"));
+        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("GET bookstore/book/1"));
         assertThat(TestSpanReceiver.getAllSpans().get(0).getKVAnnotations().size(), equalTo(1));
         
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_TRACE_ID),
equalTo("10"));
@@ -138,7 +138,7 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         assertEquals(Status.OK.getStatusCode(), r.getStatus());
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
-        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("bookstore/process"));
+        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("PUT bookstore/process"));
         assertThat(TestSpanReceiver.getAllSpans().get(0).getTimelineAnnotations().size(),
equalTo(0));
         assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("Processing
books"));
         assertThat(TestSpanReceiver.getAllSpans().get(1).getTimelineAnnotations().size(),
equalTo(1));
@@ -169,7 +169,7 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         assertEquals(Status.OK.getStatusCode(), r.getStatus());
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
-        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("bookstore/books/async"));
+        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("GET bookstore/books/async"));
         assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("Processing
books"));
         
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_TRACE_ID),
equalTo("10"));
@@ -185,7 +185,8 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         assertEquals(Status.OK.getStatusCode(), r.getStatus());
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(1));
-        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("bookstore/books/async/notrace"));
+        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), 
+            equalTo("GET bookstore/books/async/notrace"));
         
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_TRACE_ID),
equalTo("10"));
         assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID),
equalTo("20"));
@@ -197,7 +198,7 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase
{
         assertEquals(Status.OK.getStatusCode(), r.getStatus());
         
         assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
-        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("bookstore/books/async"));
+        assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("GET bookstore/books/async"));
         assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("Processing
books"));
     }
     


Mime
View raw message