use of com.uber.jaeger.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
Span jaegerSpan = (Span) tracer.buildSpan("raza").startManual();
com.uber.jaeger.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan(jaegerSpan);
Process process = new Process(tracer.getServiceName()).setTags(JaegerThriftSpanConverter.buildTags(tracer.tags()));
AutoExpandingBufferWriteTransport memoryTransport = new AutoExpandingBufferWriteTransport(maxPacketSize, 2);
process.write(new TCompactProtocol(memoryTransport));
int processSize = memoryTransport.getPos();
memoryTransport.reset();
span.write(new TCompactProtocol((memoryTransport)));
int spanSize = memoryTransport.getPos();
// 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) + sender.EMIT_BATCH_OVERHEAD + processSize;
int maxPacketSizeLeft = maxPacketSize - sender.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 com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class HttpSenderTest method sendWithoutAuthData.
@Test
public void sendWithoutAuthData() throws Exception {
System.setProperty(Configuration.JAEGER_ENDPOINT, target("/api/traces").getUri().toString());
HttpSender sender = (HttpSender) Configuration.SenderConfiguration.fromEnv().getSender();
sender.send(new Process("robotrock"), generateSpans());
}
use of com.uber.jaeger.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 (TException te) {
assertTrue(te.getMessage().contains("response 401"));
}
}
use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class HttpSenderTest method sendServerError.
@Test(expected = TException.class)
public void sendServerError() throws Exception {
HttpSender sender = new HttpSender(target("/api/tracesErr").getUri().toString());
sender.send(new Process("robotrock"), generateSpans());
}
use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.
the class UdpSenderTest method calculateBatchOverheadDifference.
private int calculateBatchOverheadDifference(int numberOfSpans) throws Exception {
AutoExpandingBufferWriteTransport memoryTransport = new AutoExpandingBufferWriteTransport(maxPacketSize, 2);
Agent.Client memoryClient = new Agent.Client(new TCompactProtocol((memoryTransport)));
Span jaegerSpan = (Span) tracer.buildSpan("raza").startManual();
com.uber.jaeger.thriftjava.Span span = JaegerThriftSpanConverter.convertSpan(jaegerSpan);
List<com.uber.jaeger.thriftjava.Span> spans = new ArrayList<>();
for (int i = 0; i < numberOfSpans; i++) {
spans.add(span);
}
memoryClient.emitBatch(new Batch(new Process(SERVICE_NAME), spans));
int emitBatchOverheadMultipleSpans = memoryTransport.getPos();
memoryTransport.reset();
for (int j = 0; j < numberOfSpans; j++) {
span.write(new TCompactProtocol(memoryTransport));
}
int writeBatchOverheadMultipleSpans = memoryTransport.getPos();
return emitBatchOverheadMultipleSpans - writeBatchOverheadMultipleSpans;
}
Aggregations