Search in sources :

Example 26 with ConstSampler

use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class SpanTest method testSetAndGetBaggageItem.

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

Example 27 with ConstSampler

use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class SpanTest method setUp.

@Before
public void setUp() {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    clock = mock(Clock.class);
    metrics = new Metrics(metricsFactory);
    tracer = new Tracer.Builder("SamplerTest", reporter, new ConstSampler(true)).withMetrics(metrics).withClock(clock).withBaggageRestrictionManager(new DefaultBaggageRestrictionManager()).withExpandExceptionLogs().build();
    span = (Span) tracer.buildSpan("some-operation").start();
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) InMemoryMetricsFactory(com.uber.jaeger.metrics.InMemoryMetricsFactory) Metrics(com.uber.jaeger.metrics.Metrics) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Clock(com.uber.jaeger.utils.Clock) DefaultBaggageRestrictionManager(com.uber.jaeger.baggage.DefaultBaggageRestrictionManager) Before(org.junit.Before)

Example 28 with ConstSampler

use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class TracerTest method testAsChildOfAcceptNull.

@Test
public void testAsChildOfAcceptNull() {
    tracer = new Tracer.Builder("foo", new InMemoryReporter(), new ConstSampler(true)).build();
    Span span = (Span) tracer.buildSpan("foo").asChildOf((Span) null).start();
    span.finish();
    assertTrue(span.getReferences().isEmpty());
    span = (Span) tracer.buildSpan("foo").asChildOf((io.opentracing.SpanContext) null).start();
    span.finish();
    assertTrue(span.getReferences().isEmpty());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Builder(com.uber.jaeger.Tracer.Builder) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Test(org.junit.Test)

Example 29 with ConstSampler

use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class BaggageSetterTest method setUp.

@Before
public void setUp() throws Exception {
    metricsFactory = new InMemoryMetricsFactory();
    reporter = new InMemoryReporter();
    metrics = new Metrics(metricsFactory);
    mgr = mock(DefaultBaggageRestrictionManager.class);
    setter = new BaggageSetter(mgr, metrics);
    tracer = new Tracer.Builder(SERVICE, reporter, new ConstSampler(true)).withMetrics(metrics).build();
    span = (Span) tracer.buildSpan("some-operation").startManual();
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) InMemoryMetricsFactory(com.uber.jaeger.metrics.InMemoryMetricsFactory) Metrics(com.uber.jaeger.metrics.Metrics) Tracer(com.uber.jaeger.Tracer) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Before(org.junit.Before)

Example 30 with ConstSampler

use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.

the class InMemoryMetricsFactoryTest method emptyValueForTag.

@Test
public void emptyValueForTag() {
    InMemoryMetricsFactory metricsFactory = new InMemoryMetricsFactory();
    Tracer tracer = new Tracer.Builder("metricsFactoryTest", new InMemoryReporter(), new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
    tracer.buildSpan("theoperation").start();
    assertEquals(-1, metricsFactory.getCounter("jaeger:started_spans", "sampled"));
    assertEquals(-1, metricsFactory.getCounter("jaeger:started_spans", ""));
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Tracer(com.uber.jaeger.Tracer) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Test(org.junit.Test)

Aggregations

ConstSampler (com.uber.jaeger.samplers.ConstSampler)33 InMemoryReporter (com.uber.jaeger.reporters.InMemoryReporter)26 Test (org.junit.Test)19 Tracer (com.uber.jaeger.Tracer)12 Before (org.junit.Before)11 Metrics (com.uber.jaeger.metrics.Metrics)9 InMemoryMetricsFactory (com.uber.jaeger.metrics.InMemoryMetricsFactory)5 Scope (io.opentracing.Scope)5 Builder (com.uber.jaeger.Tracer.Builder)4 InMemoryStatsReporter (com.uber.jaeger.metrics.InMemoryStatsReporter)3 NullStatsReporter (com.uber.jaeger.metrics.NullStatsReporter)3 StatsFactoryImpl (com.uber.jaeger.metrics.StatsFactoryImpl)3 TextMap (io.opentracing.propagation.TextMap)3 HashMap (java.util.HashMap)3 DefaultBaggageRestrictionManager (com.uber.jaeger.baggage.DefaultBaggageRestrictionManager)2 RemoteReporter (com.uber.jaeger.reporters.RemoteReporter)2 Sampler (com.uber.jaeger.samplers.Sampler)2 HttpSender (com.uber.jaeger.senders.HttpSender)2 Tracer (io.opentracing.Tracer)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1