Class ConstantSampler

  • All Implemented Interfaces:
    Sampler

    public class ConstantSampler
    extends java.lang.Object
    implements Sampler
    This is a implementation of Sampler which always returns the same sampling decision.
    • Method Detail

      • of

        public static Sampler of​(boolean decision)
      • isSampled

        public boolean isSampled​(Id traceId)
        Description copied from interface: Sampler
        Determines whether the given transaction should be sampled.
        Specified by:
        isSampled in interface Sampler
        Parameters:
        traceId - The id of the transaction.
        Returns:
        The sampling decision.
      • getSampleRate

        public double getSampleRate()
        Specified by:
        getSampleRate in interface Sampler
        Returns:
        current sample rate
      • getTraceStateHeader

        public java.lang.String getTraceStateHeader()
        Specified by:
        getTraceStateHeader in interface Sampler
        Returns:
        sample rate as (constant) header for context propagation

        While the tracestate header is not related to sampler itself, putting this here allows to reuse the same String instance as long as the sample rate does not change to minimize allocation