use of io.jaegertracing.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class HttpSenderTest method sanityTestForTokenAuthTest.
@Test
public void sanityTestForTokenAuthTest() throws Exception {
System.setProperty(Configuration.JAEGER_ENDPOINT, target("/api/bearer").getUri().toString());
System.setProperty(Configuration.JAEGER_AUTH_TOKEN, "invalid-token");
HttpSender sender = (HttpSender) Configuration.SenderConfiguration.fromEnv().getSender();
try {
sender.send(new Process("robotrock"), generateSpans());
fail("expecting exception");
} catch (Exception te) {
assertTrue(te.getMessage().contains("response 401"));
}
}
use of io.jaegertracing.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class HttpSenderTest method sendHappy.
@Test
public void sendHappy() throws Exception {
new HttpSender.Builder(target("/api/traces").getUri().toString()).build().send(new Process("robotrock"), generateSpans());
new HttpSender.Builder(target("/api/traces").getUri().toString()).withMaxPacketSize(6500).build().send(new Process("name"), generateSpans());
new HttpSender.Builder(target("/api/traces").getUri().toString()).withMaxPacketSize(6500).withClient(new OkHttpClient()).build().send(new Process("name"), generateSpans());
}
use of io.jaegertracing.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class HttpSenderTest method serverDoesntExist.
@Test(expected = Exception.class)
public void serverDoesntExist() throws Exception {
HttpSender sender = new HttpSender.Builder("http://some-server/api/traces").build();
sender.send(new Process("robotrock"), generateSpans());
}
use of io.jaegertracing.thriftjava.Process 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.thriftjava.Process 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);
}
Aggregations