Package brave.http

Class HttpSampler

  • Direct Known Subclasses:
    HttpRuleSampler

    public abstract class HttpSampler
    extends java.lang.Object
    Decides whether to start a new trace based on http request properties such as path.

    Ex. Here's a sampler that only traces api requests

    {@code
     httpTracingBuilder.serverSampler(new HttpSampler() {
    See Also:
    HttpRuleSampler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static HttpSampler NEVER_SAMPLE
      Returns false to never start new traces for http requests.
      static HttpSampler TRACE_ID
      Ignores the request and uses the trace ID instead.
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpSampler()  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract <Req> java.lang.Boolean trySample​(HttpAdapter<Req,​?> adapter, Req request)
      Returns an overriding sampling decision for a new trace.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRACE_ID

        public static final HttpSampler TRACE_ID
        Ignores the request and uses the trace ID instead.
      • NEVER_SAMPLE

        public static final HttpSampler NEVER_SAMPLE
        Returns false to never start new traces for http requests. For example, you may wish to only capture traces if they originated from an inbound server request. Such a policy would filter out client requests made during bootstrap.
    • Constructor Detail

      • HttpSampler

        public HttpSampler()
    • Method Detail

      • trySample

        @Nullable
        public abstract <Req> java.lang.Boolean trySample​(HttpAdapter<Req,​?> adapter,
                                                          Req request)
        Returns an overriding sampling decision for a new trace. Return null ignore the request and use the trace ID sampler.