Collector { public void accept(List<Span> spans, Callback<Void> callback) { accept(spans, callback, Runnable::run); } Collector(Builder builder); static Builder newBuilder(Class<?> loggingClass); void accept(List<Span> spans, Callback<Void> callback); void accept(List<Span> spans, Callback<Void> callback, Executor executor); void acceptSpans(ByteBuffer encoded, SpanBytesDecoder decoder, Callback<Void> callback,
    Executor executor); void acceptSpans(byte[] serialized, Callback<Void> callback); void acceptSpans(
    byte[] serializedSpans, BytesDecoder<Span> decoder, Callback<Void> callback);  }
@Test public void unsampledSpansArentStored() { collector = new Collector.Builder(LoggerFactory.getLogger("")) .sampler(CollectorSampler.create(0.0f)) .metrics(metrics) .storage(storage) .build(); collector.accept(TRACE, callback); verify(callback).onSuccess(null); assertThat(testLogger.getLoggingEvents()).isEmpty(); verify(metrics).incrementSpans(4); verify(metrics).incrementSpansDropped(4); assertThat(storage.getTraces()).isEmpty(); }
@Test public void accept_storageError() { StorageComponent storage = mock(StorageComponent.class); RuntimeException error = new RuntimeException("storage disabled"); when(storage.spanConsumer()).thenThrow(error); collector = new Collector.Builder(LoggerFactory.getLogger("")) .metrics(metrics) .storage(storage) .build(); collector.accept(TRACE, callback); verify(callback).onSuccess(null); assertDebugLogIs("Cannot store spans [1, 2, 2, ...] due to RuntimeException(storage disabled)"); verify(metrics).incrementSpans(4); verify(metrics).incrementSpansDropped(4); }