use of zipkin2.collector.Collector in project zipkin by openzipkin.
the class ITActiveMQCollector method skipsOnSpanStorageException.
/**
* Guards against errors that leak from storage, such as InvalidQueryException
*/
@Test
public void skipsOnSpanStorageException() throws Exception {
collector.close();
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();
}
};
activemq.pushMessage(collector.queue, PROTO3.encodeList(spans));
// tossed on error
activemq.pushMessage(collector.queue, PROTO3.encodeList(spans));
activemq.pushMessage(collector.queue, PROTO3.encodeList(spans));
collector = builder().storage(buildStorage(consumer)).build().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(activemqMetrics.messages()).isEqualTo(3);
// storage failure not message failure
assertThat(activemqMetrics.messagesDropped()).isZero();
assertThat(activemqMetrics.bytes()).isEqualTo(PROTO3.encodeList(spans).length * 3);
assertThat(activemqMetrics.spans()).isEqualTo(spans.size() * 3);
// only one dropped
assertThat(activemqMetrics.spansDropped()).isEqualTo(spans.size());
}
use of zipkin2.collector.Collector 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.collector.Collector in project zipkin by openzipkin.
the class ITScribeCollector method normal.
@Test
void normal() throws Exception {
// Java version of this sample code
// https://github.com/facebookarchive/scribe/wiki/Logging-Messages
TTransport transport = new TFramedTransport(new TSocket("localhost", server.port()));
TProtocol protocol = new TBinaryProtocol(transport, false, false);
Scribe.Iface client = new Scribe.Client(protocol);
List<LogEntry> entries = TestObjects.TRACE.stream().map(ITScribeCollector::logEntry).collect(Collectors.toList());
transport.open();
try {
ResultCode code = client.Log(entries);
assertThat(code).isEqualTo(ResultCode.OK);
code = client.Log(entries);
assertThat(code).isEqualTo(ResultCode.OK);
} finally {
transport.close();
}
verify(collector, times(2)).accept(eq(TestObjects.TRACE), any(), eq(CommonPools.blockingTaskExecutor()));
verify(metrics, times(2)).incrementMessages();
}
use of zipkin2.collector.Collector in project zipkin-azure by openzipkin.
the class EventHubCollectorTest method check_failsOnRuntimeException_registration.
@Test
public void check_failsOnRuntimeException_registration() {
RuntimeException exception = new RuntimeException();
EventHubCollector collector = new EventHubCollector(new LazyFuture() {
@Override
protected Future<?> compute() {
registration.completeExceptionally(exception);
return registration;
}
});
CheckResult result = collector.check();
assertThat(result.error()).isEqualTo(exception);
}
use of zipkin2.collector.Collector in project zipkin-azure by openzipkin.
the class EventHubCollectorTest method check_failsOnRuntimeException_registering.
@Test
public void check_failsOnRuntimeException_registering() {
RuntimeException exception = new RuntimeException();
EventHubCollector collector = new EventHubCollector(new LazyFuture() {
@Override
protected Future<?> compute() {
throw exception;
}
});
CheckResult result = collector.check();
assertThat(result.error()).isEqualTo(exception);
}
Aggregations