use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class FilterIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
metricsReporter = new InMemoryStatsReporter();
reporter = new InMemoryReporter();
tracer = new com.uber.jaeger.Tracer.Builder("some-op-name", reporter, new ConstSampler(true)).withStatsReporter(metricsReporter).build();
// start the server
server = new JerseyServer(tracer);
server.start();
// create the client
client = ClientBuilder.newClient().register(new ClientFilter(tracer)).register(JacksonFeature.class);
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class ThriftSpanConverterTest method testTracerTags.
@Test
@UseDataProvider("dataProviderTracerTags")
public void testTracerTags(SpanType spanType, Map<String, String> expectedTags) throws Exception {
InMemoryReporter spanReporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("x", spanReporter, new ConstSampler(true)).withZipkinSharedRpcSpan().withTag("tag.str", "y").withTag("tag.bool", true).withTag("tag.num", 1).build();
Span span = (Span) tracer.buildSpan("root").startManual();
if (spanType == SpanType.CHILD) {
span = (Span) tracer.buildSpan("child").asChildOf(span).startManual();
} else if (spanType == SpanType.RPC_SERVER) {
span = (Span) tracer.buildSpan("rpc-server").asChildOf(span).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).startManual();
}
com.twitter.zipkin.thriftjava.Span zipkinSpan = ThriftSpanConverter.convertSpan(span);
List<BinaryAnnotation> annotations = zipkinSpan.getBinary_annotations();
for (Map.Entry<String, String> entry : expectedTags.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
BinaryAnnotation anno = findBinaryAnnotation(annotations, key);
if (expectedValue.equals(UNDEF)) {
assertNull("Not expecting " + key + " for " + spanType, anno);
} else if (expectedValue.equals(ANY)) {
assertEquals(key, anno.getKey());
} else {
String actualValue = new String(anno.getValue(), StandardCharsets.UTF_8);
assertEquals("Expecting " + key + " for " + spanType, expectedValue, actualValue);
}
}
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class ConfigurationTest method testConstSampler.
@Test
public void testConstSampler() {
SamplerConfiguration samplerConfiguration = new SamplerConfiguration().withType(ConstSampler.TYPE);
Sampler sampler = samplerConfiguration.createSampler("name", new Metrics(new StatsFactoryImpl(new NullStatsReporter())));
assertTrue(sampler instanceof ConstSampler);
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testIgnoreActiveSpan.
@Test
public void testIgnoreActiveSpan() {
InMemoryReporter reporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("test", reporter, new ConstSampler(true)).build();
try (Scope parent = tracer.buildSpan("parent").startActive(true)) {
tracer.buildSpan("child").ignoreActiveSpan().startActive(true).close();
}
assertEquals(2, reporter.getSpans().size());
Span childSpan = reporter.getSpans().get(0);
Span parentSpan = reporter.getSpans().get(1);
assertTrue(reporter.getSpans().get(0).getReferences().isEmpty());
assertTrue(reporter.getSpans().get(1).getReferences().isEmpty());
assertNotEquals(parentSpan.context().getTraceId(), childSpan.context().getTraceId());
assertEquals(0, childSpan.context().getParentId());
}
use of com.uber.jaeger.samplers.ConstSampler in project jaeger-client-java by jaegertracing.
the class PropagationTest method testNoAutoRefWithExistingRefs.
@Test
public void testNoAutoRefWithExistingRefs() {
InMemoryReporter reporter = new InMemoryReporter();
Tracer tracer = new Tracer.Builder("test", reporter, new ConstSampler(true)).build();
io.opentracing.Span initialSpan = tracer.buildSpan("initial").start();
try (Scope parent = tracer.buildSpan("parent").startActive(true)) {
tracer.buildSpan("child").asChildOf(initialSpan.context()).startActive(true).close();
}
initialSpan.finish();
assertEquals(3, reporter.getSpans().size());
Span childSpan = reporter.getSpans().get(0);
Span parentSpan = reporter.getSpans().get(1);
Span initSpan = reporter.getSpans().get(2);
assertTrue(initSpan.getReferences().isEmpty());
assertTrue(parentSpan.getReferences().isEmpty());
assertEquals(initSpan.context().getTraceId(), childSpan.context().getTraceId());
assertEquals(initSpan.context().getSpanId(), childSpan.context().getParentId());
assertEquals(0, initSpan.context().getParentId());
assertEquals(0, parentSpan.context().getParentId());
}
Aggregations