Tracing implements Closeable { public static Builder newBuilder() { return new Builder(); } Tracing(); static Builder newBuilder(); abstract Tracer tracer(); abstract Propagation<String> propagation(); @Deprecated abstract Propagation.Factory propagationFactory(); abstract Sampler sampler(); abstract CurrentTraceContext currentTraceContext(); final Clock clock(TraceContext context); @Deprecated abstract ErrorParser errorParser(); @Nullable static Tracing current(); @Nullable static Tracer currentTracer(); abstract boolean isNoop(); abstract void setNoop(boolean noop); @Override abstract void close();  }
@Test public void localEndpointDefaults() { Tracing tracing = Tracing.newBuilder().build(); assertThat(tracing).extracting("tracer.pendingSpans.defaultSpan.localServiceName") .isEqualTo("unknown"); assertThat(tracing).extracting("tracer.pendingSpans.defaultSpan.localIp") .isEqualTo(Platform.get().linkLocalIp()); }
@Test public void localServiceNamePreservesCase() { String expectedLocalServiceName = "FavStar"; Tracing.Builder builder = Tracing.newBuilder().localServiceName(expectedLocalServiceName); assertThat(builder).extracting("defaultSpan.localServiceName") .isEqualTo(expectedLocalServiceName); }
@Test public void spanHandlers_clearAndAdd() { SpanHandler one = mock(SpanHandler.class); SpanHandler two = mock(SpanHandler.class); SpanHandler three = mock(SpanHandler.class); Tracing.Builder builder = Tracing.newBuilder() .addSpanHandler(one) .addSpanHandler(two) .addSpanHandler(three); Set<SpanHandler> spanHandlers = builder.spanHandlers(); builder.clearSpanHandlers(); spanHandlers.forEach(builder::addSpanHandler); assertThat(builder) .usingRecursiveComparison() .isEqualTo(Tracing.newBuilder() .addSpanHandler(one) .addSpanHandler(two) .addSpanHandler(three)); }