use of zipkin2.storage.StorageComponent in project zipkin by openzipkin.
the class ITRabbitMQCollector method skipsOnSpanStorageException.
/**
* Guards against errors that leak from storage, such as InvalidQueryException
*/
@Test
void skipsOnSpanStorageException() throws Exception {
AtomicInteger counter = new AtomicInteger();
consumer = (input) -> new Call.Base<Void>() {
@Override
protected Void doExecute() {
throw new AssertionError();
}
@Override
protected void doEnqueue(Callback<Void> callback) {
if (counter.getAndIncrement() == 1) {
callback.onError(new RuntimeException("storage fell over"));
} else {
receivedSpans.add(spans);
callback.onSuccess(null);
}
}
@Override
public Call<Void> clone() {
throw new AssertionError();
}
};
final StorageComponent storage = buildStorage(consumer);
RabbitMQCollector.Builder builder = builder("storage_exception").storage(storage);
produceSpans(THRIFT.encodeList(spans), builder.queue);
// tossed on error
produceSpans(THRIFT.encodeList(spans), builder.queue);
produceSpans(THRIFT.encodeList(spans), builder.queue);
try (RabbitMQCollector collector = builder.build()) {
collector.start();
assertThat(receivedSpans.take()).containsExactlyElementsOf(spans);
// the only way we could read this, is if the malformed span was skipped.
assertThat(receivedSpans.take()).containsExactlyElementsOf(spans);
}
assertThat(rabbitmqMetrics.messages()).isEqualTo(3);
// storage failure isn't a message failure
assertThat(rabbitmqMetrics.messagesDropped()).isZero();
assertThat(rabbitmqMetrics.bytes()).isEqualTo(THRIFT.encodeList(spans).length * 3);
assertThat(rabbitmqMetrics.spans()).isEqualTo(spans.size() * 3);
// only one dropped
assertThat(rabbitmqMetrics.spansDropped()).isEqualTo(spans.size());
}
use of zipkin2.storage.StorageComponent in project zipkin by openzipkin.
the class ZipkinHttpConfigurationTest method search_canDisable.
@Test
public void search_canDisable() {
TestPropertyValues.of("zipkin.storage.search-enabled:false").applyTo(context);
registerBaseConfig(context);
context.refresh();
StorageComponent v2Storage = context.getBean(StorageComponent.class);
assertThat(v2Storage).extracting("searchEnabled").isEqualTo(false);
}
use of zipkin2.storage.StorageComponent in project zipkin by openzipkin.
the class ThrottledStorageComponentTest method delegatesCheck.
@Test
public void delegatesCheck() {
StorageComponent mock = mock(StorageComponent.class);
new ThrottledStorageComponent(mock, registry, tracing, 1, 2, 1).check();
verify(mock, times(1)).check();
}
use of zipkin2.storage.StorageComponent in project zipkin by openzipkin.
the class ITKafkaCollector method skipsOnSpanStorageException.
/**
* Guards against errors that leak from storage, such as InvalidQueryException
*/
@Test
void skipsOnSpanStorageException() throws Exception {
AtomicInteger counter = new AtomicInteger();
consumer = (input) -> new Call.Base<Void>() {
@Override
protected Void doExecute() {
throw new AssertionError();
}
@Override
protected void doEnqueue(Callback<Void> callback) {
if (counter.getAndIncrement() == 1) {
callback.onError(new RuntimeException("storage fell over"));
} else {
receivedSpans.add(spans);
callback.onSuccess(null);
}
}
@Override
public Call<Void> clone() {
throw new AssertionError();
}
};
final StorageComponent storage = buildStorage(consumer);
KafkaCollector.Builder builder = builder("storage_exception").storage(storage);
produceSpans(THRIFT.encodeList(spans), builder.topic);
// tossed on error
produceSpans(THRIFT.encodeList(spans), builder.topic);
produceSpans(THRIFT.encodeList(spans), builder.topic);
try (KafkaCollector collector = builder.build()) {
collector.start();
assertThat(receivedSpans.take()).containsExactlyElementsOf(spans);
// the only way we could read this, is if the malformed span was skipped.
assertThat(receivedSpans.take()).containsExactlyElementsOf(spans);
}
assertThat(kafkaMetrics.messages()).isEqualTo(3);
// storage failure isn't a message failure
assertThat(kafkaMetrics.messagesDropped()).isZero();
assertThat(kafkaMetrics.bytes()).isEqualTo(THRIFT.encodeList(spans).length * 3);
assertThat(kafkaMetrics.spans()).isEqualTo(spans.size() * 3);
// only one dropped
assertThat(kafkaMetrics.spansDropped()).isEqualTo(spans.size());
}
use of zipkin2.storage.StorageComponent in project zipkin by openzipkin.
the class CollectorTest method accept_storageError.
@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);
// error is async
verify(callback).onSuccess(null);
assertDebugLogIs("Cannot store spans [1, 2, 2, ...] due to RuntimeException(storage disabled)");
verify(metrics).incrementSpans(4);
verify(metrics).incrementSpansDropped(4);
}
Aggregations