Search in sources :

Example 1 with LogEntry

use of zipkin2.collector.scribe.generated.LogEntry 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 LogEntry

use of zipkin2.collector.scribe.generated.LogEntry in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method consumerExceptionBeforeCallbackDoesntSetFutureException.

@Test
void consumerExceptionBeforeCallbackDoesntSetFutureException() {
    consumer = (input) -> {
        throw new NullPointerException("endpoint was null");
    };
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = encodedSpan;
    CaptureAsyncMethodCallback callback = new CaptureAsyncMethodCallback();
    scribe.Log(asList(entry), callback);
    // Storage related exceptions are not propagated to the caller. Only marshalling ones are.
    assertThat(callback.error).isNull();
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isZero();
    assertThat(scribeMetrics.bytes()).isEqualTo(bytes.length);
    assertThat(scribeMetrics.spans()).isEqualTo(1);
    assertThat(scribeMetrics.spansDropped()).isEqualTo(1);
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 3 with LogEntry

use of zipkin2.collector.scribe.generated.LogEntry in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method malformedDataIsDropped.

@Test
void malformedDataIsDropped() {
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = "notbase64";
    CaptureAsyncMethodCallback callback = new CaptureAsyncMethodCallback();
    scribe.Log(asList(entry), callback);
    assertThat(callback.error).isInstanceOf(IllegalArgumentException.class);
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(scribeMetrics.messages()).isEqualTo(1));
    assertThat(scribeMetrics.messagesDropped()).isEqualTo(1);
    assertThat(scribeMetrics.bytes()).isZero();
    assertThat(scribeMetrics.spans()).isZero();
    assertThat(scribeMetrics.spansDropped()).isZero();
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 4 with LogEntry

use of zipkin2.collector.scribe.generated.LogEntry in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method decodesSpanGeneratedByFinagle.

/**
 * Finagle's zipkin tracer breaks on a column width with a trailing newline
 */
@Test
void decodesSpanGeneratedByFinagle() throws Exception {
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = "" + "CgABq/sBMnzE048LAAMAAAAOZ2V0VHJhY2VzQnlJZHMKAATN0p+4EGfTdAoABav7ATJ8xNOPDwAGDAAAAAQKAAEABR/wq+2DeAsAAgAAAAJzcgwAAwgAAX8AAAEGAAIkwwsAAwAAAAx6aXBraW4tcXVlcnkAAAoAAQAFH/Cr7zj4CwACAAAIAGFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh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hYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhDAADCAABfwAAAQYAAiTDCwADAAAADHppcGtpbi1xdWVyeQAACgABAAUf8KwLPyILAAIAAABOR2MoOSwwLlBTU2NhdmVuZ2UsMjAxNS0wOS0xNyAxMjozNzowMiArMDAwMCwzMDQubWlsbGlzZWNvbmRzKzc2Mi5taWNyb3NlY29uZHMpDAADCAABfwAAAQYAAiTDCwADAAAADHppcGtpbi1xdWVyeQAIAAQABKZ6AAoAAQAFH/CsDLfACwACAAAAAnNzDAADCAABfwAAAQYAAiTDCwADAAAADHppcGtpbi1xdWVyeQAADwAIDAAAAAULAAEAAAATc3J2L2ZpbmFnbGUudmVyc2lvbgsAAgAAAAY2LjI4LjAIAAMAAAAGDAAECAABfwAAAQYAAgAACwADAAAADHppcGtpbi1xdWVyeQAACwABAAAAD3Nydi9tdXgvZW5hYmxlZAsAAgAAAAEBCAADAAAAAAwABAgAAX8AAAEGAAIAAAsAAwAAAAx6aXBraW4tcXVlcnkAAAsAAQAAAAJzYQsAAgAAAAEBCAADAAAAAAwABAgAAX8AAAEGAAIkwwsAAwAAAAx6aXBraW4tcXVlcnkAAAsAAQAAAAJjYQsAAgAAAAEBCAADAAAAAAwABAgAAX8AAAEGAAL5YAsAAwAAAAx6aXBraW4tcXVlcnkAAAsAAQAAAAZudW1JZHMLAAIAAAAEAAAAAQgAAwAAAAMMAAQIAAF/AAABBgACJMMLAAMAAAAMemlwa2luLXF1ZXJ5AAACAAkAAA==\n";
    ScribeSpanConsumer scribe = newScribeSpanConsumer(entry.category, consumer);
    expectSuccess(scribe, entry);
    // Storage finishes after callback so wait for it.
    await().untilAsserted(() -> assertThat(storage.getTraces()).containsExactly(asList(v2)));
    assertThat(scribeMetrics.messages()).isEqualTo(1);
    assertThat(scribeMetrics.messagesDropped()).isZero();
    assertThat(scribeMetrics.bytes()).isEqualTo(Base64.getMimeDecoder().decode(entry.message).length);
    assertThat(scribeMetrics.spans()).isEqualTo(1);
    assertThat(scribeMetrics.spansDropped()).isZero();
}
Also used : LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Example 5 with LogEntry

use of zipkin2.collector.scribe.generated.LogEntry in project zipkin by openzipkin.

the class ScribeSpanConsumerTest method callbackExceptionDoesntThrow.

/**
 * Callbacks are performed asynchronously. If they throw, it hints that we are chaining futures
 * when we shouldn't
 */
@Test
void callbackExceptionDoesntThrow() throws Exception {
    consumer = (input) -> new Call.Base<Void>() {

        @Override
        protected Void doExecute() {
            throw new AssertionError();
        }

        @Override
        protected void doEnqueue(Callback<Void> callback) {
            callback.onError(new NullPointerException());
        }

        @Override
        public Call<Void> clone() {
            throw new AssertionError();
        }
    };
    ScribeSpanConsumer scribe = newScribeSpanConsumer("zipkin", consumer);
    LogEntry entry = new LogEntry();
    entry.category = "zipkin";
    entry.message = encodedSpan;
    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()).isEqualTo(bytes.length);
    assertThat(scribeMetrics.spans()).isEqualTo(1);
    assertThat(scribeMetrics.spansDropped()).isEqualTo(1);
}
Also used : Call(zipkin2.Call) LogEntry(zipkin2.collector.scribe.generated.LogEntry) Test(org.junit.jupiter.api.Test)

Aggregations

LogEntry (zipkin2.collector.scribe.generated.LogEntry)8 Test (org.junit.jupiter.api.Test)7 Call (zipkin2.Call)2 Span (zipkin2.Span)2 ResultCode (zipkin2.collector.scribe.generated.ResultCode)2 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 ArrayList (java.util.ArrayList)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 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 TSocket (org.apache.thrift.transport.TSocket)1 TTransport (org.apache.thrift.transport.TTransport)1 TFramedTransport (org.apache.thrift.transport.layered.TFramedTransport)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Awaitility.await (org.awaitility.Awaitility.await)1