Class RuleBasedRoutingSampler

java.lang.Object
io.opentelemetry.contrib.sampler.RuleBasedRoutingSampler
All Implemented Interfaces:
io.opentelemetry.sdk.trace.samplers.Sampler, Closeable, AutoCloseable

public final class RuleBasedRoutingSampler extends Object implements io.opentelemetry.sdk.trace.samplers.Sampler
This sampler accepts a list of SamplingRules and tries to match every proposed span against those rules. Every rule describes a span's attribute, a pattern against which to match attribute's value, and a sampler that will make a decision about given span if match was successful.

Matching is performed by Pattern.

Provided span kind is checked first and if differs from the one given to builder(SpanKind, Sampler), the default fallback sampler will make a decision.

Note that only attributes that were set on SpanBuilder will be taken into account, attributes set after the span has been started are not used

If none of the rules matched, the default fallback sampler will make a decision.

  • Method Summary

    Modifier and Type
    Method
    Description
    builder(io.opentelemetry.api.trace.SpanKind kind, io.opentelemetry.sdk.trace.samplers.Sampler fallback)
     
     
    io.opentelemetry.sdk.trace.samplers.SamplingResult
    shouldSample(io.opentelemetry.context.Context parentContext, String traceId, String name, io.opentelemetry.api.trace.SpanKind spanKind, io.opentelemetry.api.common.Attributes attributes, List<io.opentelemetry.sdk.trace.data.LinkData> parentLinks)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.opentelemetry.sdk.trace.samplers.Sampler

    close, shutdown
  • Method Details

    • builder

      public static RuleBasedRoutingSamplerBuilder builder(io.opentelemetry.api.trace.SpanKind kind, io.opentelemetry.sdk.trace.samplers.Sampler fallback)
    • shouldSample

      public io.opentelemetry.sdk.trace.samplers.SamplingResult shouldSample(io.opentelemetry.context.Context parentContext, String traceId, String name, io.opentelemetry.api.trace.SpanKind spanKind, io.opentelemetry.api.common.Attributes attributes, List<io.opentelemetry.sdk.trace.data.LinkData> parentLinks)
      Specified by:
      shouldSample in interface io.opentelemetry.sdk.trace.samplers.Sampler
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface io.opentelemetry.sdk.trace.samplers.Sampler
    • toString

      public String toString()
      Overrides:
      toString in class Object