From commits-return-1750-archive-asf-public=cust-asf.ponee.io@zipkin.apache.org Mon Jun 3 04:28:06 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 366CD18067C for ; Mon, 3 Jun 2019 06:28:05 +0200 (CEST) Received: (qmail 49526 invoked by uid 500); 3 Jun 2019 04:28:04 -0000 Mailing-List: contact commits-help@zipkin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zipkin.apache.org Delivered-To: mailing list commits@zipkin.apache.org Received: (qmail 49498 invoked by uid 99); 3 Jun 2019 04:28:04 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Jun 2019 04:28:04 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 72FFB8A866; Mon, 3 Jun 2019 04:28:04 +0000 (UTC) Date: Mon, 03 Jun 2019 04:28:05 +0000 To: "commits@zipkin.apache.org" Subject: [incubator-zipkin-brave] 01/02: Backfills test of setNoop behavior MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: adriancole@apache.org In-Reply-To: <155953608435.19699.1430516378206214889@gitbox.apache.org> References: <155953608435.19699.1430516378206214889@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-zipkin-brave X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 2b19ec8b79b6a48cca8d3cbf45eef4b13d373ae7 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190603042804.72FFB8A866@gitbox.apache.org> 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 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(); }