cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [cxf] branch master updated: [CXF-7608] Propagate trace ids as it lets log correlation to be consistent even if not sampling (#367)
Date Wed, 17 Jan 2018 13:46:51 GMT
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 15ba7ed  [CXF-7608] Propagate trace ids as it lets log correlation to be consistent
even if not sampling (#367)
15ba7ed is described below

commit 15ba7ed5135bed28c2b22bb29f3eb487c5602850
Author: Aldo Sinanaj <aldex32@hotmail.com>
AuthorDate: Wed Jan 17 14:46:48 2018 +0100

    [CXF-7608] Propagate trace ids as it lets log correlation to be consistent even if not
sampling (#367)
---
 .../cxf/tracing/brave/AbstractBraveClientProvider.java    |  2 +-
 .../apache/cxf/tracing/brave/AbstractBraveProvider.java   |  2 +-
 .../cxf/systest/jaxrs/tracing/brave/BraveTracingTest.java | 15 +++++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
index bd208f2..7bc4bcb 100644
--- a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
@@ -66,7 +66,7 @@ public abstract class AbstractBraveClientProvider extends AbstractTracingProvide
         // In case of asynchronous client invocation, the span should be detached as JAX-RS
         // client request / response filters are going to be executed in different threads.
         SpanInScope scope = null;
-        if (!isAsyncInvocation() && span != null && !span.isNoop()) {
+        if (!isAsyncInvocation() && span != null) {
             scope = brave.tracing().tracer().withSpanInScope(span);
         }
 
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveProvider.java
b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveProvider.java
index 46d9862..aff576d 100644
--- a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveProvider.java
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveProvider.java
@@ -69,7 +69,7 @@ public abstract class AbstractBraveProvider extends AbstractTracingProvider
{
         if (isAsyncResponse() && span != null) {
            // Do not modify the current context span
             propagateContinuationSpan(span);
-        } else if (span != null && !span.isNoop()) {
+        } else if (span != null) {
             scope = brave.tracing().tracer().withSpanInScope(span);
         }
 
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 5bdf9bb..d972d6d 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
@@ -373,6 +373,21 @@ public class BraveTracingTest extends AbstractBusClientServerTestBase
{
         assertThatTraceIsPresent(r, spanId);
     }
 
+    @Test
+    public void testThatNoSpansAreRecordedWhenNotSampled() {
+        final Tracing never = Tracing
+                .newBuilder()
+                .reporter(new TestSpanReporter())
+                .sampler(Sampler.NEVER_SAMPLE)
+                .build();
+
+        final Response r = createWebClient("/bookstore/books", new BraveClientProvider(never)).get();
+        assertEquals(Status.OK.getStatusCode(), r.getStatus());
+
+        assertThat(TestSpanReporter.getAllSpans().size(), equalTo(0));
+        assertThatTraceHeadersArePresent(r, false);
+    }
+
     protected WebClient createWebClient(final String url, final Object ... providers) {
         return WebClient
             .create("http://localhost:" + PORT + url, Arrays.asList(providers))

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <commits@cxf.apache.org>'].

Mime
View raw message