Search in sources :

Example 16 with ConstSampler

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);
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) JacksonFeature(org.glassfish.jersey.jackson.JacksonFeature) InMemoryStatsReporter(com.uber.jaeger.metrics.InMemoryStatsReporter) Tracer(io.opentracing.Tracer) ConstSampler(com.uber.jaeger.samplers.ConstSampler) ClientFilter(com.uber.jaeger.filters.jaxrs2.ClientFilter) Before(org.junit.Before)

Example 17 with ConstSampler

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);
        }
    }
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Tracer(com.uber.jaeger.Tracer) Span(com.uber.jaeger.Span) BinaryAnnotation(com.twitter.zipkin.thriftjava.BinaryAnnotation) ConstSampler(com.uber.jaeger.samplers.ConstSampler) HashMap(java.util.HashMap) Map(java.util.Map) TextMap(io.opentracing.propagation.TextMap) TreeMap(java.util.TreeMap) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 18 with ConstSampler

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);
}
Also used : Metrics(com.uber.jaeger.metrics.Metrics) NullStatsReporter(com.uber.jaeger.metrics.NullStatsReporter) RateLimitingSampler(com.uber.jaeger.samplers.RateLimitingSampler) Sampler(com.uber.jaeger.samplers.Sampler) ConstSampler(com.uber.jaeger.samplers.ConstSampler) ProbabilisticSampler(com.uber.jaeger.samplers.ProbabilisticSampler) SamplerConfiguration(com.uber.jaeger.Configuration.SamplerConfiguration) ConstSampler(com.uber.jaeger.samplers.ConstSampler) StatsFactoryImpl(com.uber.jaeger.metrics.StatsFactoryImpl) Test(org.junit.Test)

Example 19 with 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());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Scope(io.opentracing.Scope) ConstSampler(com.uber.jaeger.samplers.ConstSampler) Test(org.junit.Test)

Example 20 with ConstSampler

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());
}
Also used : InMemoryReporter(com.uber.jaeger.reporters.InMemoryReporter) Scope(io.opentracing.Scope) 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