use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class UdpSenderTest method testAppendMaxSize.
@Test
public void testAppendMaxSize() throws Exception {
Process process = new Process(tracer.getServiceName()).setTags(JaegerThriftSpanConverter.buildTags(tracer.tags()));
int processSize = sender.getSize(process);
JaegerSpan jaegerSpan = buildSpanWithSize(maxPacketSize - UdpSender.EMIT_BATCH_OVERHEAD - processSize);
int result = sender.append(jaegerSpan);
assertEquals(1, result);
// test if the buffer is reinitialized correctly
result = sender.append(jaegerSpan);
assertEquals(1, result);
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class UdpSenderTest method testFlushSendsSpanWith128BitTraceId.
@Test
public void testFlushSendsSpanWith128BitTraceId() throws Exception {
// in milliseconds
int timeout = 50;
int expectedNumSpans = 1;
JaegerSpan expectedSpan = tracer128.buildSpan("raza").start();
assertEquals(0, sender.append(expectedSpan));
assertEquals(1, sender.flush());
Batch batch = server.getBatch(expectedNumSpans, timeout);
assertEquals(expectedNumSpans, batch.getSpans().size());
io.jaegertracing.thriftjava.Span actualSpan = batch.getSpans().get(0);
assertEquals(expectedSpan.context().getTraceIdLow(), actualSpan.getTraceIdLow());
assertEquals(expectedSpan.context().getTraceIdHigh(), actualSpan.getTraceIdHigh());
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class UdpSenderTest method testAppend.
@Test
public void testAppend() throws Exception {
// find size of the initial span
JaegerSpan jaegerSpan = tracer.buildSpan("raza").start();
io.jaegertracing.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan(jaegerSpan);
Process process = new Process(tracer.getServiceName()).setTags(JaegerThriftSpanConverter.buildTags(tracer.tags()));
int processSize = sender.getSize(process);
int spanSize = sender.getSize(span);
// create a sender thats a multiple of the span size (accounting for span overhead)
// this allows us to test the boundary conditions of writing spans.
int expectedNumSpans = 11;
int maxPacketSize = (spanSize * expectedNumSpans) + UdpSender.EMIT_BATCH_OVERHEAD + processSize;
int maxPacketSizeLeft = maxPacketSize - UdpSender.EMIT_BATCH_OVERHEAD - processSize;
// add enough spans to be under buffer limit
sender = new UdpSender(destHost, destPort, maxPacketSize);
while (spanSize < maxPacketSizeLeft) {
sender.append(jaegerSpan);
maxPacketSizeLeft -= spanSize;
}
// add a span that overflows the limit to hit the last branch
int result = sender.append(jaegerSpan);
assertEquals(expectedNumSpans, result);
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class V2SpanConverter method convertSpan.
public static zipkin2.Span convertSpan(JaegerSpan span) {
JaegerTracer tracer = span.getTracer();
zipkin2.Endpoint.Builder host = zipkin2.Endpoint.newBuilder().serviceName(tracer.getServiceName());
if (tracer.getIpv4() != 0) {
host.parseIp(convertIp(tracer.getIpv4()));
}
zipkin2.Endpoint peerEndpoint = extractPeerEndpoint(span.getTags());
JaegerSpanContext context = span.context();
zipkin2.Span.Builder builder = zipkin2.Span.newBuilder().id(Long.toHexString(context.getSpanId())).traceId(context.getTraceIdHigh(), context.getTraceIdLow()).name(span.getOperationName()).parentId(Long.toHexString(context.getParentId())).debug(context.isDebug()).localEndpoint(host.build()).remoteEndpoint(peerEndpoint).kind(convertKind(span.getTags().get(Tags.SPAN_KIND.getKey()))).timestamp(span.getStart()).duration(span.getDuration());
buildAnnotations(span, builder);
buildTags(span, builder);
return builder.build();
}
use of io.jaegertracing.internal.JaegerSpan in project jaeger-client-java by jaegertracing.
the class ZipkinSenderTest method testAppendSpanTooLarge.
@Test
public void testAppendSpanTooLarge() {
JaegerSpan jaegerSpan = tracer.buildSpan("raza").start();
String msg = "";
for (int i = 0; i < 1001; i++) {
msg += ".";
}
jaegerSpan.log(msg);
try {
sender.append(jaegerSpan);
fail("The line above shoud throw");
} catch (SenderException e) {
assertEquals(e.getDroppedSpanCount(), 1);
}
}
Aggregations