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
Date Fri, 22 May 2015 00:01:56 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 580366ccf -> e2ec36443


CXF-6360: Integration with Apache HTrace


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

Branch: refs/heads/master
Commit: e2ec3644381789e0cabf40262139940aa33bc7c1
Parents: 580366c
Author: reta <drreta@gmail.com>
Authored: Thu May 21 20:01:44 2015 -0400
Committer: reta <drreta@gmail.com>
Committed: Thu May 21 20:01:44 2015 -0400

----------------------------------------------------------------------
 .../jaxrs/tracing/htrace/HTraceProvider.java    | 23 ++++++--------------
 1 file changed, 7 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e2ec3644/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
index 4c0977c..57dc29a 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
@@ -44,19 +44,10 @@ import static org.apache.cxf.tracing.TracerHeaders.HEADER_TRACE_ID;
 @Provider
 public class HTraceProvider implements ContainerRequestFilter, ContainerResponseFilter {

     private static final Logger LOG = LogUtils.getL7dLogger(HTraceProvider.class);
+    private static final String TRACE_SPAN = "org.apache.cxf.jaxrs.tracing.htrace.span";
         
     private final Sampler< ? > sampler;
     
-    // Keep the parent spans in the thread-local storage. The span created during request
-    // phase should be closed during the response phase in order to mark the start/end 
-    // bounds 
-    private final ThreadLocal<TraceScope> parent = new ThreadLocal<TraceScope>()
{
-        @Override
-        protected TraceScope initialValue() {
-            return null;
-        }
-    };
-    
     public HTraceProvider() {
         this(NeverSampler.INSTANCE);
     }
@@ -79,8 +70,8 @@ public class HTraceProvider implements ContainerRequestFilter, ContainerResponse
             Tracer.DONT_TRACE.spanId); 
         
         if (traceId != Tracer.DONT_TRACE.traceId && spanId != Tracer.DONT_TRACE.spanId)
{
-            parent.set(Trace.startSpan(requestContext.getUriInfo().getPath(), (Sampler<
TraceInfo >)sampler,
-                new TraceInfo(traceId, spanId)));
+            requestContext.setProperty(TRACE_SPAN, Trace.startSpan(requestContext.getUriInfo().getPath(),

+                (Sampler< TraceInfo >)sampler, new TraceInfo(traceId, spanId)));
         }
     }
     
@@ -95,10 +86,10 @@ public class HTraceProvider implements ContainerRequestFilter, ContainerResponse
             responseContext.getHeaders().add(HEADER_SPAN_ID, headers.getFirst(HEADER_SPAN_ID));
         }
         
-        try (final TraceScope span = parent.get()) {
-            if (span != null) {
-                parent.remove();
-            }
+        final Object value = requestContext.getProperty(TRACE_SPAN);
+        if (value instanceof TraceScope) {
+            final TraceScope span = (TraceScope)value;
+            span.close();
         }
     }
     


Mime
View raw message