Search in sources :

Example 31 with ConstSampler

use of io.jaegertracing.internal.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class RemoteReporterTest method testUpdateSuccessMetricWhenAppendFlushed.

@Test
public void testUpdateSuccessMetricWhenAppendFlushed() throws InterruptedException {
    int totalSpans = 3;
    int flushSize = 2;
    CountDownLatch latch = new CountDownLatch(1);
    sender = new InMemorySender() {

        @Override
        public int append(JaegerSpan span) {
            try {
                super.append(span);
                if (getAppended().size() >= flushSize) {
                    return flush();
                }
                if (getReceived().size() == totalSpans) {
                    latch.countDown();
                }
                return 0;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    reporter = new Builder().withSender(sender).withFlushInterval(Integer.MAX_VALUE).withMaxQueueSize(maxQueueSize).withMetrics(metrics).build();
    tracer = new JaegerTracer.Builder("test-remote-reporter").withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).build();
    for (int i = 0; i < totalSpans; i++) {
        reporter.report(newSpan());
    }
    latch.await(1, TimeUnit.SECONDS);
    assertEquals(flushSize, metricsFactory.getCounter("jaeger_tracer_reporter_spans", "result=ok"));
    assertEquals(0, metricsFactory.getCounter("jaeger_tracer_reporter_spans", "result=err"));
    assertEquals(0, metricsFactory.getCounter("jaeger_tracer_reporter_spans", "result=dropped"));
}
Also used : Builder(io.jaegertracing.internal.reporters.RemoteReporter.Builder) JaegerSpan(io.jaegertracing.internal.JaegerSpan) InMemorySender(io.jaegertracing.internal.senders.InMemorySender) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) CountDownLatch(java.util.concurrent.CountDownLatch) SenderException(io.jaegertracing.internal.exceptions.SenderException) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 32 with ConstSampler

use of io.jaegertracing.internal.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class RemoteReporterTest method testCloseWhenQueueFull.

@Test
@Ignore("See https://github.com/jaegertracing/jaeger-client-java/issues/340")
public void testCloseWhenQueueFull() {
    int closeTimeoutMillis = 5;
    reporter = new RemoteReporter.Builder().withSender(sender).withFlushInterval(Integer.MAX_VALUE).withMaxQueueSize(maxQueueSize).withCloseEnqueueTimeout(closeTimeoutMillis).withMetrics(metrics).build();
    tracer = new JaegerTracer.Builder("test-remote-reporter").withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).build();
    // change sender to blocking mode
    sender.permitAppend(0);
    // fill the queue
    for (int i = 0; i < maxQueueSize + 10; i++) {
        reporter.report(newSpan());
    }
    reporter.close();
// expect no exception thrown
}
Also used : ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Builder(io.jaegertracing.internal.reporters.RemoteReporter.Builder) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 33 with ConstSampler

use of io.jaegertracing.internal.samplers.ConstSampler in project wso2-synapse by wso2.

the class OpenTracingManagerHolder method loadZipkinConfigurations.

/**
 * Loads Zipkin configurations required for the OpenTracingManager.
 *
 * @param zipkinBackendURL
 */
public static void loadZipkinConfigurations(String zipkinBackendURL) {
    ZipkinV2ReporterFactory factory = new ZipkinV2ReporterFactory(zipkinBackendURL);
    ConstSampler sampler = new ConstSampler(true);
    openTracingManager = new JaegerTracingManager(sampler, factory.getReporter());
}
Also used : JaegerTracingManager(org.apache.synapse.aspects.flow.statistics.opentracing.management.JaegerTracingManager) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ZipkinV2ReporterFactory(org.apache.synapse.aspects.flow.statistics.opentracing.management.helpers.zipkin.ZipkinV2ReporterFactory)

Aggregations

ConstSampler (io.jaegertracing.internal.samplers.ConstSampler)33 InMemoryReporter (io.jaegertracing.internal.reporters.InMemoryReporter)22 JaegerTracer (io.jaegertracing.internal.JaegerTracer)21 Test (org.junit.Test)19 Before (org.junit.Before)13 InMemoryMetricsFactory (io.jaegertracing.internal.metrics.InMemoryMetricsFactory)9 Metrics (io.jaegertracing.internal.metrics.Metrics)7 JaegerSpan (io.jaegertracing.internal.JaegerSpan)6 Builder (io.jaegertracing.internal.reporters.RemoteReporter.Builder)5 InMemorySender (io.jaegertracing.internal.senders.InMemorySender)4 Builder (io.jaegertracing.internal.JaegerTracer.Builder)3 TextMap (io.opentracing.propagation.TextMap)3 HashMap (java.util.HashMap)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 DefaultBaggageRestrictionManager (io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager)2 SenderException (io.jaegertracing.internal.exceptions.SenderException)2 Sampler (io.jaegertracing.spi.Sampler)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2