Package brave.http

Class HttpRuleSampler


  • public final class HttpRuleSampler
    extends HttpSampler
    Assigns sample rates to http routes.

    Ex. Here's a sampler that traces 80% requests to /foo and 10% of POST requests to /bar. Other requests will use a global rate provided by the tracing component.

    
     httpTracingBuilder.serverSampler(HttpRuleSampler.newBuilder()
       .addRule(null, "/foo", 0.8f)
       .addRule("POST", "/bar", 0.1f)
       .build());
     

    Note that the path is a prefix, so "/foo" will match "/foo/abcd".

    • Method Detail

      • trySample

        public <Req> java.lang.Boolean trySample​(HttpAdapter<Req,​?> adapter,
                                                 Req request)
        Description copied from class: HttpSampler
        Returns an overriding sampling decision for a new trace. Return null ignore the request and use the trace ID sampler.
        Specified by:
        trySample in class HttpSampler