Search in sources :

Example 1 with SpanConsumer

use of zipkin2.storage.SpanConsumer in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method entriesWithoutSpansAreSkipped.

@Test
void entriesWithoutSpansAreSkipped() throws Exception {
    SpanConsumer consumer = (callback) -> {
        // as we shouldn't get here.
        throw new AssertionError();
    };
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "notzipkin";
    entry.message = "hello world";
    expectSuccess(scribe, entry);
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isZero();
    assertThat(scribeMetrics.bytes()).isZero();
    assertThat(scribeMetrics.spans()).isZero();
    assertThat(scribeMetrics.spansDropped()).isZero();
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) InMemoryCollectorMetrics(zipkin2.collector.InMemoryCollectorMetrics) Arrays(java.util.Arrays) ForwardingStorageComponent(zipkin2.storage.ForwardingStorageComponent) Awaitility.await(org.awaitility.Awaitility.await) SpanConsumer(zipkin2.storage.SpanConsumer) InMemoryStorage(zipkin2.storage.InMemoryStorage) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) V1SpanConverter(zipkin2.v1.V1SpanConverter) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Base64(java.util.Base64) Endpoint(zipkin2.Endpoint) Arrays.asList(java.util.Arrays.asList) SpanBytesEncoder(zipkin2.codec.SpanBytesEncoder) AsyncMethodCallback(org.apache.thrift.async.AsyncMethodCallback) Callback(zipkin2.Callback) StorageComponent(zipkin2.storage.StorageComponent) Call(zipkin2.Call) ResultCode(zipkin2.collector.scribe.generated.ResultCode) SpanConsumer(zipkin2.storage.SpanConsumer) LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 2 with SpanConsumer

use of zipkin2.storage.SpanConsumer in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method strictTraceIdFalse_setsTraceIdHigh.

@Test
public void strictTraceIdFalse_setsTraceIdHigh() {
    consumer = spanConsumer(CassandraStorage.newBuilder().strictTraceId(false));
    Span span = spanWithoutAnnotationsOrTags.toBuilder().traceId("77fcac3d4c5be8d2a037812820c65f28").build();
    AggregateCall<?, Void> call = (AggregateCall<?, Void>) consumer.accept(singletonList(span));
    assertThat(call.delegate()).filteredOn(c -> c instanceof InsertSpan).extracting("input.trace_id_high", "input.trace_id").containsExactly(tuple("77fcac3d4c5be8d2", "a037812820c65f28"));
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) Span(zipkin2.Span) Test(org.junit.Test)

Example 3 with SpanConsumer

use of zipkin2.storage.SpanConsumer in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method searchDisabled_doesntIndex.

@Test
public void searchDisabled_doesntIndex() {
    consumer = spanConsumer(CassandraStorage.newBuilder().searchEnabled(false));
    Span span = spanWithoutAnnotationsOrTags.toBuilder().addAnnotation(TODAY * 1000L, "annotation").putTag("foo", "bar").duration(10000L).build();
    assertThat(consumer.accept(singletonList(span))).extracting("input.annotation_query").satisfies(q -> assertThat(q).isNull());
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)3 Test (org.junit.Test)2 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Base64 (java.util.Base64)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TimeUnit (java.util.concurrent.TimeUnit)1 AsyncMethodCallback (org.apache.thrift.async.AsyncMethodCallback)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Awaitility.await (org.awaitility.Awaitility.await)1 Test (org.junit.jupiter.api.Test)1 Call (zipkin2.Call)1 Callback (zipkin2.Callback)1 Endpoint (zipkin2.Endpoint)1 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)1 InMemoryCollectorMetrics (zipkin2.collector.InMemoryCollectorMetrics)1 LogEntry (zipkin2.collector.scribe.generated.LogEntry)1 ResultCode (zipkin2.collector.scribe.generated.ResultCode)1 AggregateCall (zipkin2.internal.AggregateCall)1