Search in sources :

Example 6 with ConstSampler

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

the class JaegerSpanTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    clock = mock(Clock.class);
    metrics = new Metrics(metricsFactory);
    final JaegerTracer.Builder tracerBuilder = new JaegerTracer.Builder("SamplerTest").withReporter(reporter).withSampler(new ConstSampler(true)).withMetrics(metrics).withClock(clock).withBaggageRestrictionManager(new DefaultBaggageRestrictionManager()).withExpandExceptionLogs();
    tracer = tracerBuilder.build();
    tracer128 = tracerBuilder.withTraceId128Bit().build();
    jaegerSpan = tracer.buildSpan("some-operation").start();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) Metrics(io.jaegertracing.internal.metrics.Metrics) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) Clock(io.jaegertracing.internal.clock.Clock) DefaultBaggageRestrictionManager(io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager) Before(org.junit.Before)

Example 7 with ConstSampler

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

the class JaegerSpanTest method testSetAndGetBaggageItem.

@Test
public void testSetAndGetBaggageItem() {
    final String service = "SamplerTest";
    final BaggageRestrictionManager mgr = Mockito.mock(DefaultBaggageRestrictionManager.class);
    tracer = new JaegerTracer.Builder(service).withReporter(reporter).withSampler(new ConstSampler(true)).withClock(clock).withBaggageRestrictionManager(mgr).build();
    jaegerSpan = tracer.buildSpan("some-operation").start();
    final String key = "key";
    final String value = "value";
    when(mgr.getRestriction(service, key)).thenReturn(Restriction.of(true, 10));
    jaegerSpan.setBaggageItem(key, "value");
    verify(mgr).getRestriction(service, key);
    assertEquals(value, jaegerSpan.getBaggageItem(key));
}
Also used : ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) DefaultBaggageRestrictionManager(io.jaegertracing.internal.baggage.DefaultBaggageRestrictionManager) BaggageRestrictionManager(io.jaegertracing.spi.BaggageRestrictionManager) Test(org.junit.Test)

Example 8 with ConstSampler

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

the class NoopMetricsFactoryTest method canBeUsedWithMetrics.

@Test
public void canBeUsedWithMetrics() {
    NoopMetricsFactory metricsFactory = new NoopMetricsFactory();
    JaegerTracer tracer = new JaegerTracer.Builder("metricsFactoryTest").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
    tracer.buildSpan("theoperation").start();
}
Also used : InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 9 with ConstSampler

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

the class MicrometerTest method validateMetricCounts.

@Test
public void validateMetricCounts() throws InterruptedException {
    Sampler constantSampler = new ConstSampler(true);
    Configuration configuration = new Configuration("validateMetricCounts");
    JaegerTracer tracer = configuration.getTracerBuilder().withSampler(constantSampler).withMetrics(metrics).build();
    createSomeSpans(tracer);
    tracer.close();
    double finishedSpans = registry.get("jaeger_tracer_finished_spans").counter().count();
    double startedSpans = registry.get("jaeger_tracer_started_spans").tag("sampled", "y").counter().count();
    double traces = registry.get("jaeger_tracer_traces").tag("sampled", "y").tag("state", "started").counter().count();
    assertEquals("Wrong number of finishedSpans", 4.0, finishedSpans, assertDelta);
    assertEquals("Wrong number of startedSpans", 10.0, startedSpans, assertDelta);
    assertEquals("Wrong number of traces", 10.0, traces, assertDelta);
}
Also used : Configuration(io.jaegertracing.Configuration) Sampler(io.jaegertracing.spi.Sampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Test(org.junit.Test)

Example 10 with ConstSampler

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

the class ZipkinV2ReporterTest method setup.

@Before
public void setup() {
    sender = URLConnectionSender.newBuilder().encoding(Encoding.JSON).endpoint(zipkinRule.httpUrl() + "/api/v2/spans").build();
    zipkinReporter = zipkin2.reporter.AsyncReporter.builder(sender).messageTimeout(0, TimeUnit.MILLISECONDS).build();
    reporter = new ZipkinV2Reporter(zipkinReporter);
    tracer = new JaegerTracer.Builder("test-sender").withReporter(reporter).withSampler(new ConstSampler(true)).withMetricsFactory(new InMemoryMetricsFactory()).build();
}
Also used : InMemoryMetricsFactory(io.jaegertracing.internal.metrics.InMemoryMetricsFactory) ZipkinV2Reporter(io.jaegertracing.zipkin.ZipkinV2Reporter) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Before(org.junit.Before)

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