Class SamplingStrategies


  • public final class SamplingStrategies
    extends java.lang.Object
    Utility methods for sampling strategies.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleRespectRequestOrEveryN​(int sampleCountHint)
      Filter that samples as requested, but if there is no request will sample approximately sampleCountHint times.
      static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleUnlessFalse()
      Sample unless explicitly requested to not sample.
      static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleWhenRequestedOrEveryN​(int sampleCountHint)
      Filter that samples when requested, or otherwise treats no request and false as the same and will filter approximately sampleCountHint times.
      • Methods inherited from class java.lang.Object

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

      • sampleUnlessFalse

        public static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleUnlessFalse()
        Sample unless explicitly requested to not sample.
        Returns:
        A filter which samples unless explicitly requested to not sample.
      • sampleRespectRequestOrEveryN

        public static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleRespectRequestOrEveryN​(int sampleCountHint)
        Filter that samples as requested, but if there is no request will sample approximately sampleCountHint times.
        Parameters:
        sampleCountHint - Provides a hint at how many times we sample when sampling is not specified.
        Returns:
        A filter that samples as requested, but if there is no request will sample approximately sampleCountHint times.
      • sampleWhenRequestedOrEveryN

        public static java.util.function.BiFunction<java.lang.String,​java.lang.Boolean,​java.lang.Boolean> sampleWhenRequestedOrEveryN​(int sampleCountHint)
        Filter that samples when requested, or otherwise treats no request and false as the same and will filter approximately sampleCountHint times.
        Parameters:
        sampleCountHint - Provides a hint at how many times we sample when sampling is false or null.
        Returns:
        A filter that if requested, don't filter if not requested, but if requested is null a sample will be done roughly every sampleCountHint times.