use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class TracerTagsTest method testTracerTags.
@Test
public void testTracerTags() throws Exception {
InMemoryReporter spanReporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("x", spanReporter, new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tracer.tag.str", "y").build();
Span span = (Span) tracer.buildSpan("root").startManual();
// span should only contain sampler tags and no tracer tags
assertEquals(2, span.getTags().size());
assertEquals(true, span.getTags().containsKey("sampler.type"));
assertEquals(true, span.getTags().containsKey("sampler.param"));
assertEquals(false, span.getTags().containsKey("tracer.tag.str"));
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class TracerTest method testRegisterInjector.
@Test
public void testRegisterInjector() {
@SuppressWarnings("unchecked") Injector<TextMap> injector = mock(Injector.class);
Tracer tracer = new Tracer.Builder("TracerTestService", new InMemoryReporter(), new ConstSampler(true)).withMetrics(new Metrics(new InMemoryMetricsFactory())).registerInjector(Format.Builtin.TEXT_MAP, injector).build();
Span span = (Span) tracer.buildSpan("leela").start();
TextMap carrier = mock(TextMap.class);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, carrier);
verify(injector).inject(any(SpanContext.class), any(TextMap.class));
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class TracerTest method setUp.
@Before
public void setUp() throws Exception {
metricsFactory = new InMemoryMetricsFactory();
tracer = new Tracer.Builder("TracerTestService").withReporter(new InMemoryReporter()).withSampler(new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class TracerTest method testWithBaggageRestrictionManager.
@Test
public void testWithBaggageRestrictionManager() {
tracer = new Tracer.Builder("TracerTestService", new InMemoryReporter(), new ConstSampler(true)).withMetrics(new Metrics(metricsFactory)).build();
Span span = (Span) tracer.buildSpan("some-operation").start();
final String key = "key";
tracer.setBaggage(span, key, "value");
assertEquals(1, metricsFactory.getCounter("jaeger:baggage_updates", "result=ok"));
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class BaggageSetterTest method testUnsampledSpan.
@Test
public void testUnsampledSpan() {
tracer = new Tracer.Builder("SamplerTest", reporter, new ConstSampler(false)).withMetrics(metrics).build();
span = (Span) tracer.buildSpan("some-operation").startManual();
when(mgr.getRestriction(SERVICE, KEY)).thenReturn(Restriction.of(true, 5));
final String value = "value";
SpanContext ctx = setter.setBaggage(span, KEY, value);
assertEquals(value, ctx.getBaggageItem(KEY));
// No logs should be written if the span is not sampled
assertNull(span.getLogs());
}
Aggregations