Search in sources :

Example 1 with Process

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

the class ThriftSender method append.

@Override
public int append(JaegerSpan span) throws SenderException {
    if (process == null) {
        process = new Process(span.getTracer().getServiceName());
        process.setTags(JaegerThriftSpanConverter.buildTags(span.getTracer().tags()));
        processBytesSize = calculateProcessSize(process);
    }
    io.jaegertracing.thriftjava.Span thriftSpan = JaegerThriftSpanConverter.convertSpan(span);
    int spanSize = calculateSpanSize(thriftSpan);
    if (spanSize > getMaxSpanBytes()) {
        throw new SenderException(String.format("ThriftSender received a span that was too large, size = %d, max = %d", spanSize, getMaxSpanBytes()), null, 1);
    }
    spanBytesSize += spanSize;
    if (spanBytesSize <= getMaxSpanBytes()) {
        spanBuffer.add(thriftSpan);
        if (spanBytesSize < getMaxSpanBytes()) {
            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);
    spanBytesSize = spanSize;
    return n;
}
Also used : Process(io.jaegertracing.thriftjava.Process) SenderException(io.jaegertracing.internal.exceptions.SenderException)

Example 2 with Process

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

the class HttpSenderTest method sendServerError.

@Test(expected = Exception.class)
public void sendServerError() throws Exception {
    HttpSender sender = new HttpSender.Builder(target("/api/tracesErr").getUri().toString()).build();
    sender.send(new Process("robotrock"), generateSpans());
}
Also used : Process(io.jaegertracing.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with Process

use of io.jaegertracing.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(io.jaegertracing.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 4 with Process

use of io.jaegertracing.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(io.jaegertracing.thriftjava.Process) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 5 with Process

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

the class ThriftSenderTest method appendFail.

@Test(expected = SenderException.class)
public void appendFail() throws Exception {
    int size = 0;
    ThriftSender sender = new ThriftSender(ProtocolType.Compact, 0) {

        @Override
        public void send(Process process, List<Span> spans) throws SenderException {
            throw new SenderException("", null, spans.size());
        }
    };
    JaegerTracer tracer = new JaegerTracer.Builder("failure").build();
    sender.append(tracer.buildSpan("flush-fail").start());
    sender.flush();
}
Also used : Process(io.jaegertracing.thriftjava.Process) List(java.util.List) SenderException(io.jaegertracing.internal.exceptions.SenderException) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Aggregations

Process (io.jaegertracing.thriftjava.Process)14 Test (org.junit.Test)12 JerseyTest (org.glassfish.jersey.test.JerseyTest)7 SenderException (io.jaegertracing.internal.exceptions.SenderException)5 JaegerSpan (io.jaegertracing.internal.JaegerSpan)3 JaegerTracer (io.jaegertracing.internal.JaegerTracer)2 List (java.util.List)2 ThriftSender (io.jaegertracing.thrift.internal.senders.ThriftSender)1 SpanExporter (io.opencensus.trace.export.SpanExporter)1 OkHttpClient (okhttp3.OkHttpClient)1