Package brave.rpc

Class RpcRuleSampler

  • All Implemented Interfaces:
    brave.sampler.SamplerFunction<RpcRequest>

    public final class RpcRuleSampler
    extends Object
    implements brave.sampler.SamplerFunction<RpcRequest>
    Assigns sample rates to RPC requests.

    Ex. Here's a sampler that traces 100 "Report" requests per second. This doesn't start new traces for requests to the scribe service. Other requests will use a global rate provided by the tracing component.

    
     import static brave.rpc.RpcRequestMatchers.*;
    
     rpcTracingBuilder.serverSampler(RpcRuleSampler.newBuilder()
       .putRule(serviceEquals("scribe"), Sampler.NEVER_SAMPLE)
       .putRule(methodEquals("Report"), RateLimitingSampler.create(100))
       .build());
     

    Implementation notes

    Be careful when implementing matchers as RpcRequest methods can return null.
    Since:
    5.8
    See Also:
    RpcRequestMatchers