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);
}
Aggregations