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();
}
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));
}
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();
}
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);
}
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();
}
Aggregations