Search in sources :

Example 1 with Sampler

use of brave.sampler.Sampler in project brave by openzipkin.

the class HttpClientHandlerTest method handleSend_traceIdSamplerSpecialCased.

@Test
public void handleSend_traceIdSamplerSpecialCased() {
    Sampler sampler = mock(Sampler.class);
    init(httpTracingBuilder(tracingBuilder().sampler(sampler)).clientSampler(SamplerFunctions.deferDecision()));
    assertThat(handler.handleSend(request).isNoop()).isTrue();
    verify(sampler).isSampled(anyLong());
}
Also used : Sampler(brave.sampler.Sampler) Test(org.junit.Test)

Example 2 with Sampler

use of brave.sampler.Sampler in project brave by openzipkin.

the class TracerTest method sampler.

@Test
public void sampler() {
    Sampler sampler = new Sampler() {

        @Override
        public boolean isSampled(long traceId) {
            return false;
        }
    };
    tracer = Tracing.newBuilder().sampler(sampler).build().tracer();
    assertThat(tracer.sampler).isSameAs(sampler);
}
Also used : Sampler(brave.sampler.Sampler) Test(org.junit.Test)

Example 3 with Sampler

use of brave.sampler.Sampler in project brave by openzipkin.

the class TracerTest method withSampler.

@Test
public void withSampler() {
    Sampler sampler = new Sampler() {

        @Override
        public boolean isSampled(long traceId) {
            return false;
        }
    };
    tracer = tracer.withSampler(sampler);
    assertThat(tracer.sampler).isSameAs(sampler);
}
Also used : Sampler(brave.sampler.Sampler) Test(org.junit.Test)

Example 4 with Sampler

use of brave.sampler.Sampler in project brave by openzipkin.

the class AspectJSamplerTest method clear.

@Before
public void clear() {
    tracing.set(Tracing.newBuilder().currentTraceContext(currentTraceContext).addSpanHandler(spans).sampler(new Sampler() {

        @Override
        public boolean isSampled(long traceId) {
            // in this case, we aren't expecting a fallback
            throw new AssertionError();
        }
    }).build());
    spans.clear();
}
Also used : DeclarativeSampler(brave.sampler.DeclarativeSampler) Sampler(brave.sampler.Sampler) Before(org.junit.Before)

Example 5 with Sampler

use of brave.sampler.Sampler in project brave by openzipkin.

the class RpcServerHandlerTest method handleReceive_traceIdSamplerSpecialCased.

@Test
public void handleReceive_traceIdSamplerSpecialCased() {
    Sampler sampler = mock(Sampler.class);
    init(httpTracingBuilder(tracingBuilder().sampler(sampler)).serverSampler(SamplerFunctions.deferDecision()));
    assertThat(handler.handleReceive(request).isNoop()).isTrue();
    verify(sampler).isSampled(anyLong());
}
Also used : Sampler(brave.sampler.Sampler) Test(org.junit.Test)

Aggregations

Sampler (brave.sampler.Sampler)12 Test (org.junit.Test)10 DeclarativeSampler (brave.sampler.DeclarativeSampler)1 Before (org.junit.Before)1