Interface Sampler

  • All Known Implementing Classes:
    ConstantSampler, ProbabilitySampler

    public interface Sampler
    A sampler is responsible for determining whether a Transaction should be sampled.

    In contrast other tracing systems, in Elastic APM, non-sampled Transactions do get reported to the APM server. However, to keep the size at a minimum, the reported Transaction only contains the transaction name, the duration and the id. Also, Spans of non sampled Transactions are not reported.

    • Method Detail

      • isSampled

        boolean isSampled​(Id traceId)
        Determines whether the given transaction should be sampled.
        Parameters:
        traceId - The id of the transaction.
        Returns:
        The sampling decision.
      • getSampleRate

        double getSampleRate()
        Returns:
        current sample rate
      • getTraceStateHeader

        java.lang.String getTraceStateHeader()
        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