Search in sources :

Example 6 with Sampler

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

the class RpcClientHandlerTest method handleSend_neverSamplerSpecialCased.

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

Example 7 with Sampler

use of brave.sampler.Sampler in project spring-cloud-sleuth by spring-cloud.

the class ProbabilityBasedSamplerTests method countNumberOfSampledElements.

private int countNumberOfSampledElements(int numberOfIterations) {
    Sampler sampler = new ProbabilityBasedSampler(this.samplerConfiguration);
    int passedCounter = 0;
    for (int i = 0; i < numberOfIterations; i++) {
        boolean passed = sampler.isSampled(RANDOM.nextLong());
        passedCounter = passedCounter + (passed ? 1 : 0);
    }
    return passedCounter;
}
Also used : Sampler(brave.sampler.Sampler)

Example 8 with Sampler

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

the class HttpClientHandlerTest method handleSend_neverSamplerSpecialCased.

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

Example 9 with Sampler

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

the class HttpServerHandlerTest method handleReceive_neverSamplerSpecialCased.

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

Example 10 with Sampler

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

the class HttpServerHandlerTest 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