Search in sources :

Example 1 with Process

use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.

the class ThriftSender method append.

@Override
public int append(Span span) throws SenderException {
    if (process == null) {
        process = new Process(span.getTracer().getServiceName());
        process.setTags(JaegerThriftSpanConverter.buildTags(span.getTracer().tags()));
        processBytesSize = getSizeOfSerializedThrift(process);
        byteBufferSize += processBytesSize;
    }
    com.uber.jaeger.thriftjava.Span thriftSpan = JaegerThriftSpanConverter.convertSpan(span);
    int spanSize = getSizeOfSerializedThrift(thriftSpan);
    if (spanSize > maxSpanBytes) {
        throw new SenderException(String.format("ThriftSender received a span that was too large, size = %d, max = %d", spanSize, maxSpanBytes), null, 1);
    }
    byteBufferSize += spanSize;
    if (byteBufferSize <= maxSpanBytes) {
        spanBuffer.add(thriftSpan);
        if (byteBufferSize < maxSpanBytes) {
            return 0;
        }
        return flush();
    }
    int n;
    try {
        n = flush();
    } catch (SenderException e) {
        // +1 for the span not submitted in the buffer above
        throw new SenderException(e.getMessage(), e.getCause(), e.getDroppedSpanCount() + 1);
    }
    spanBuffer.add(thriftSpan);
    byteBufferSize = processBytesSize + spanSize;
    return n;
}
Also used : Process(com.uber.jaeger.thriftjava.Process) SenderException(com.uber.jaeger.exceptions.SenderException)

Example 2 with Process

use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.

the class HttpSenderTest method serverDoesntExist.

@Test(expected = TException.class)
public void serverDoesntExist() throws Exception {
    HttpSender sender = new HttpSender("http://some-server/api/traces");
    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 3 with Process

use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.

the class HttpSenderTest method sendWithTokenAuth.

@Test
public void sendWithTokenAuth() throws Exception {
    System.setProperty(Configuration.JAEGER_ENDPOINT, target("/api/bearer").getUri().toString());
    System.setProperty(Configuration.JAEGER_AUTH_TOKEN, "thetoken");
    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 4 with Process

use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.

the class HttpSenderTest method sendHappy.

@Test
public void sendHappy() throws Exception {
    new HttpSender(target("/api/traces").getUri().toString()).send(new Process("robotrock"), generateSpans());
    new HttpSender(target("/api/traces").getUri().toString(), 6500).send(new Process("name"), generateSpans());
    new HttpSender(target("/api/traces").getUri().toString(), 6500, new OkHttpClient()).send(new Process("name"), generateSpans());
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Process(com.uber.jaeger.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 5 with Process

use of com.uber.jaeger.thriftjava.Process in project jaeger-client-java by jaegertracing.

the class HttpSenderTest method sendWithBasicAuth.

@Test
public void sendWithBasicAuth() throws Exception {
    System.setProperty(Configuration.JAEGER_ENDPOINT, target("/api/basic-auth").getUri().toString());
    System.setProperty(Configuration.JAEGER_USER, "jdoe");
    System.setProperty(Configuration.JAEGER_PASSWORD, "password");
    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)

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