Search in sources :

Example 6 with Process

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);
}
Also used : AutoExpandingBufferWriteTransport(org.apache.thrift.transport.AutoExpandingBufferWriteTransport) Process(com.uber.jaeger.thriftjava.Process) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) Span(com.uber.jaeger.Span) Test(org.junit.Test)

Example 7 with Process

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());
}
Also used : Process(com.uber.jaeger.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 8 with Process

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"));
    }
}
Also used : TException(org.apache.thrift.TException) Process(com.uber.jaeger.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 9 with Process

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());
}
Also used : Process(com.uber.jaeger.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 10 with Process

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;
}
Also used : AutoExpandingBufferWriteTransport(org.apache.thrift.transport.AutoExpandingBufferWriteTransport) Agent(com.uber.jaeger.agent.thrift.Agent) ArrayList(java.util.ArrayList) Process(com.uber.jaeger.thriftjava.Process) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) Span(com.uber.jaeger.Span) Batch(com.uber.jaeger.thriftjava.Batch)

Aggregations

Process (com.uber.jaeger.thriftjava.Process)10 Test (org.junit.Test)8 JerseyTest (org.glassfish.jersey.test.JerseyTest)7 Span (com.uber.jaeger.Span)2 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)2 AutoExpandingBufferWriteTransport (org.apache.thrift.transport.AutoExpandingBufferWriteTransport)2 Agent (com.uber.jaeger.agent.thrift.Agent)1 SenderException (com.uber.jaeger.exceptions.SenderException)1 Batch (com.uber.jaeger.thriftjava.Batch)1 ArrayList (java.util.ArrayList)1 OkHttpClient (okhttp3.OkHttpClient)1 TException (org.apache.thrift.TException)1