Collector { void handleDecodeError(Throwable e, Callback<Void> callback) { metrics.incrementMessagesDropped(); handleError(e, "Cannot decode spans"::toString, callback); } 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 handleDecodeError_onErrorWithNullMessage() { RuntimeException error = new RuntimeException(); collector.handleDecodeError(error, callback); verify(callback).onError(error); assertDebugLogIs("Cannot decode spans due to RuntimeException()"); verify(metrics).incrementMessagesDropped(); }
@Test public void handleDecodeError_onErrorWithMessage() { IllegalArgumentException error = new IllegalArgumentException("no beer"); collector.handleDecodeError(error, callback); verify(callback).onError(error); assertDebugLogIs("Cannot decode spans due to IllegalArgumentException(no beer)"); verify(metrics).incrementMessagesDropped(); }
@Test public void handleDecodeError_doesntWrapMessageOnMalformedException() { IllegalArgumentException error = new IllegalArgumentException("Malformed reading spans"); collector.handleDecodeError(error, callback); verify(callback).onError(error); assertDebugLogIs("Malformed reading spans"); verify(metrics).incrementMessagesDropped(); }
@Test public void handleDecodeError_doesntWrapMessageOnTruncatedException() { IllegalArgumentException error = new IllegalArgumentException("Truncated reading spans"); collector.handleDecodeError(error, callback); verify(callback).onError(error); assertDebugLogIs("Truncated reading spans"); verify(metrics).incrementMessagesDropped(); }