Class EventSampler

  • All Implemented Interfaces:
    Sampler

    @API(EXPERIMENTAL)
    public class EventSampler
    extends java.lang.Object
    implements Sampler
    A Sampler which will aim for a long-term stable throughput at or less than a certain fraction of events (instead of per unit time).

    This sampler will compute whether an item can be sampled based on a number of events, rather than as a function of time, so the long-term throughput is measured in samples/event. Event sampling is useful when you have a consistent steady-state of incoming events, and you just want to take a limited sample of those events, but don't care about shaping those events at all (e.g. you don't want to allow bursty traffic or anything like that). This is mainly because the way EventSampling tracks time is by the passage of events, so it will only ever allow through samples as a fraction of events, no matter how irregular in time those events may be. If you are interested in a sampling method that captures time-irregular traffic patterns, then you should be sampling according to time-rates, rather than even rates.

    • Constructor Summary

      Constructors 
      Constructor Description
      EventSampler​(int maxSamplesPerEvent, long refreshIntervalEvents)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canSample()
      Determine if an element can be sampled.
      • Methods inherited from class java.lang.Object

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

      • EventSampler

        public EventSampler​(int maxSamplesPerEvent,
                            long refreshIntervalEvents)
    • Method Detail

      • canSample

        public boolean canSample()
        Description copied from interface: Sampler
        Determine if an element can be sampled.
        Specified by:
        canSample in interface Sampler
        Returns:
        true if an element can be sampled, false otherwise.