Search in sources :

Example 6 with SenderException

use of io.jaegertracing.internal.exceptions.SenderException 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)

Example 7 with SenderException

use of io.jaegertracing.internal.exceptions.SenderException in project jaeger-client-java by jaegertracing.

the class ThriftSenderTest method flushFail.

@Test(expected = SenderException.class)
public void flushFail() throws Exception {
    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)

Example 8 with SenderException

use of io.jaegertracing.internal.exceptions.SenderException in project jaeger-client-java by jaegertracing.

the class UdpSenderTest method testAppendSpanTooLarge.

@Test(expected = SenderException.class)
public void testAppendSpanTooLarge() 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 + 1);
    try {
        sender.append(jaegerSpan);
    } catch (SenderException e) {
        assertEquals(e.getDroppedSpanCount(), 1);
        throw e;
    }
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) Process(io.jaegertracing.thriftjava.Process) SenderException(io.jaegertracing.internal.exceptions.SenderException) Test(org.junit.Test)

Example 9 with SenderException

use of io.jaegertracing.internal.exceptions.SenderException in project opentelemetry-java by open-telemetry.

the class JaegerThriftSpanExporter method export.

/**
 * Submits all the given spans in a single batch to the Jaeger collector.
 *
 * @param spans the list of sampled Spans to be exported.
 * @return the result of the operation
 */
@Override
public CompletableResultCode export(Collection<SpanData> spans) {
    Map<Process, List<Span>> batches = spans.stream().collect(Collectors.groupingBy(SpanData::getResource)).entrySet().stream().collect(Collectors.toMap(entry -> createProcess(entry.getKey()), entry -> Adapter.toJaeger(entry.getValue())));
    List<CompletableResultCode> batchResults = new ArrayList<>(batches.size());
    batches.forEach((process, jaegerSpans) -> {
        CompletableResultCode batchResult = new CompletableResultCode();
        batchResults.add(batchResult);
        try {
            // todo: consider making truly async
            thriftSender.send(process, jaegerSpans);
            batchResult.succeed();
        } catch (SenderException e) {
            logger.log(Level.WARNING, "Failed to export spans", e);
            batchResult.fail();
        }
    });
    return CompletableResultCode.ofAll(batchResults);
}
Also used : ThrottlingLogger(io.opentelemetry.sdk.internal.ThrottlingLogger) Resource(io.opentelemetry.sdk.resources.Resource) Span(io.jaegertracing.thriftjava.Span) Collection(java.util.Collection) SpanExporter(io.opentelemetry.sdk.trace.export.SpanExporter) ThreadSafe(javax.annotation.concurrent.ThreadSafe) Logger(java.util.logging.Logger) UnknownHostException(java.net.UnknownHostException) Collectors(java.util.stream.Collectors) ResourceAttributes(io.opentelemetry.semconv.resource.attributes.ResourceAttributes) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) InetAddress(java.net.InetAddress) TagType(io.jaegertracing.thriftjava.TagType) List(java.util.List) ThriftSender(io.jaegertracing.thrift.internal.senders.ThriftSender) Map(java.util.Map) SpanData(io.opentelemetry.sdk.trace.data.SpanData) Process(io.jaegertracing.thriftjava.Process) SenderException(io.jaegertracing.internal.exceptions.SenderException) Tag(io.jaegertracing.thriftjava.Tag) CompletableResultCode(io.opentelemetry.sdk.common.CompletableResultCode) SpanData(io.opentelemetry.sdk.trace.data.SpanData) CompletableResultCode(io.opentelemetry.sdk.common.CompletableResultCode) ArrayList(java.util.ArrayList) Process(io.jaegertracing.thriftjava.Process) ArrayList(java.util.ArrayList) List(java.util.List) SenderException(io.jaegertracing.internal.exceptions.SenderException)

Example 10 with SenderException

use of io.jaegertracing.internal.exceptions.SenderException in project jaeger-client-java by jaegertracing.

the class ZipkinSenderTest method testAppendSpanTooLarge.

@Test
public void testAppendSpanTooLarge() {
    JaegerSpan jaegerSpan = tracer.buildSpan("raza").start();
    String msg = "";
    for (int i = 0; i < 1001; i++) {
        msg += ".";
    }
    jaegerSpan.log(msg);
    try {
        sender.append(jaegerSpan);
        fail("The line above shoud throw");
    } catch (SenderException e) {
        assertEquals(e.getDroppedSpanCount(), 1);
    }
}
Also used : JaegerSpan(io.jaegertracing.internal.JaegerSpan) SenderException(io.jaegertracing.internal.exceptions.SenderException) Test(org.junit.Test)

Aggregations

SenderException (io.jaegertracing.internal.exceptions.SenderException)11 Test (org.junit.Test)6 Process (io.jaegertracing.thriftjava.Process)5 JaegerSpan (io.jaegertracing.internal.JaegerSpan)3 JaegerTracer (io.jaegertracing.internal.JaegerTracer)3 List (java.util.List)3 Builder (io.jaegertracing.internal.reporters.RemoteReporter.Builder)2 InMemorySender (io.jaegertracing.internal.senders.InMemorySender)2 Endpoint (com.twitter.zipkin.thriftjava.Endpoint)1 ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)1 ThriftSender (io.jaegertracing.thrift.internal.senders.ThriftSender)1 Batch (io.jaegertracing.thriftjava.Batch)1 Span (io.jaegertracing.thriftjava.Span)1 Tag (io.jaegertracing.thriftjava.Tag)1 TagType (io.jaegertracing.thriftjava.TagType)1 CompletableResultCode (io.opentelemetry.sdk.common.CompletableResultCode)1 ThrottlingLogger (io.opentelemetry.sdk.internal.ThrottlingLogger)1 Resource (io.opentelemetry.sdk.resources.Resource)1 SpanData (io.opentelemetry.sdk.trace.data.SpanData)1 SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)1