Search in sources :

Example 1 with ThriftSpanEncoder

use of io.jaegertracing.zipkin.internal.ThriftSpanEncoder in project jaeger-client-java by jaegertracing.

the class ZipkinSenderTest method testAppend.

@Test
public void testAppend() throws Exception {
    JaegerSpan jaegerSpan = tracer.buildSpan("raza").start();
    com.twitter.zipkin.thriftjava.Span span = ThriftSpanConverter.convertSpan(jaegerSpan);
    int expectedNumSpans = 11;
    List<byte[]> spansToSend = new ArrayList<>(expectedNumSpans);
    for (int i = 0; i < expectedNumSpans; i++) {
        spansToSend.add(new ThriftSpanEncoder().encode(ZipkinSender.backFillHostOnAnnotations(span)));
    }
    // create a sender that's a multiple of the span size (accounting for span overhead)
    // this allows us to test the boundary conditions of writing spans.
    int messageMaxBytes = sender.delegate.messageSizeInBytes(spansToSend);
    sender.close();
    sender = newSender(messageMaxBytes);
    // add enough spans to be under buffer limit
    for (int i = 0; i < expectedNumSpans - 1; i++) {
        assertEquals(0, sender.append(jaegerSpan));
    }
    // add a span that overflows the limit to hit the last branch
    int result = sender.append(jaegerSpan);
    assertEquals(expectedNumSpans, result);
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) ArrayList(java.util.ArrayList) ThriftSpanEncoder(io.jaegertracing.zipkin.internal.ThriftSpanEncoder) Test(org.junit.Test)

Aggregations

JaegerSpan (io.jaegertracing.internal.JaegerSpan)1 ThriftSpanEncoder (io.jaegertracing.zipkin.internal.ThriftSpanEncoder)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1