zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adrianc...@apache.org
Subject [incubator-zipkin-brave] 01/02: Backfills test of setNoop behavior
Date Mon, 03 Jun 2019 04:28:05 GMT
This is an automated email from the ASF dual-hosted git repository.

adriancole pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-brave.git

commit 2b19ec8b79b6a48cca8d3cbf45eef4b13d373ae7
Author: Adrian Cole <acole@pivotal.io>
AuthorDate: Tue Apr 23 08:24:46 2019 +0900

    Backfills test of setNoop behavior
---
 brave/src/test/java/brave/TracingTest.java | 34 +++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/brave/src/test/java/brave/TracingTest.java b/brave/src/test/java/brave/TracingTest.java
index a02fbff..39fedcd 100644
--- a/brave/src/test/java/brave/TracingTest.java
+++ b/brave/src/test/java/brave/TracingTest.java
@@ -41,6 +41,34 @@ public class TracingTest {
     }
   };
 
+  /**
+   * This behavior could be problematic as downstream services may report spans based on
+   * propagated sampled status, and be missing a parent when their parent tracer is in noop.
+   */
+  @Test public void setNoop_dropsDataButDoesntAffectSampling() {
+    try (Tracing tracing = Tracing.newBuilder().spanReporter(spans::add).build()) {
+      ScopedSpan parent = tracing.tracer().startScopedSpan("parent");
+
+      tracing.setNoop(true);
+
+      // a new child retains sampled from parent even in noop
+      brave.Span child = tracing.tracer().newChild(parent.context());
+      assertThat(child.context().sampled()).isTrue();
+      assertThat(child.isNoop()).isTrue();
+      child.finish();
+
+      parent.finish();
+
+      // a new trace is sampled from even when noop
+      brave.Span root = tracing.tracer().newTrace();
+      assertThat(root.context().sampled()).isTrue();
+      assertThat(root.isNoop()).isTrue();
+      root.finish();
+    }
+
+    assertThat(spans).isEmpty();
+  }
+
   @Test public void spanReporter_getsLocalEndpointInfo() {
     String expectedLocalServiceName = "favistar", expectedLocalIp = "1.2.3.4";
     int expectedLocalPort = 80;
@@ -116,9 +144,9 @@ public class TracingTest {
 
   @Test public void firehose_recordsWhenReporterIsNoopIfAlwaysSampleLocal() {
     try (Tracing tracing = Tracing.newBuilder()
-        .spanReporter(Reporter.NOOP)
-        .addFinishedSpanHandler(finishedSpanHandler)
-        .build()) {
+      .spanReporter(Reporter.NOOP)
+      .addFinishedSpanHandler(finishedSpanHandler)
+      .build()) {
       tracing.tracer().newTrace().start().name("aloha").finish();
     }
 


Mime
View raw message