Search in sources :

Example 1 with HttpRequest

use of brave.http.HttpRequest in project brave by openzipkin.

the class ITHttpServer method customSampler.

@Test
public void customSampler() throws IOException {
    String path = "/foo";
    SamplerFunction<HttpRequest> sampler = HttpRuleSampler.newBuilder().putRule(pathStartsWith(path), Sampler.NEVER_SAMPLE).build();
    httpTracing = httpTracing.toBuilder().serverSampler(sampler).build();
    init();
    Request request = new Request.Builder().url(url(path)).build();
    try (Response response = client.newCall(request).execute()) {
        assertThat(response.isSuccessful()).isTrue();
    }
// @After will check that nothing is reported
}
Also used : HttpRequest(brave.http.HttpRequest) Response(okhttp3.Response) HttpRequest(brave.http.HttpRequest) Request(okhttp3.Request) Test(org.junit.Test)

Example 2 with HttpRequest

use of brave.http.HttpRequest in project brave by openzipkin.

the class ITHttpClient method customSampler.

@Test
public void customSampler() throws IOException {
    String path = "/foo";
    closeClient(client);
    SamplerFunction<HttpRequest> sampler = HttpRuleSampler.newBuilder().putRule(pathStartsWith(path), Sampler.NEVER_SAMPLE).build();
    httpTracing = httpTracing.toBuilder().clientSampler(sampler).build();
    client = newClient(server.getPort());
    server.enqueue(new MockResponse());
    get(client, path);
    assertThat(extract(takeRequest()).sampled()).isFalse();
}
Also used : HttpRequest(brave.http.HttpRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.junit.Test)

Aggregations

HttpRequest (brave.http.HttpRequest)2 Test (org.junit.Test)2 Request (okhttp3.Request)1 Response (okhttp3.Response)1 MockResponse (okhttp3.mockwebserver.MockResponse)1