Skip to main content

%Trace.ParentBasedSampler

class %Trace.ParentBasedSampler extends %Trace.AbstractSampler

Returns a decision based on the Span Parent (parent sampled flag and local vs. remote).
ParentBasedSampler distinguishes between the following cases:
  • No parent (root span).
  • Remote parent (SpanContext.IsRemote() == true) with SampledFlag set
  • Remote parent (SpanContext.IsRemote() == true) with SampledFlag not set
  • Local parent (SpanContext.IsRemote() == false) with SampledFlag set
  • Local parent (SpanContext.IsRemote() == false) with SampledFlag not set

    Based on the case, ParentBasedSampler will then call other delegated Samplers, as defined by the %OnNew() Parameters, to create the SamplingResult. The Parameters should be the ClassName of the Sampler, or the short ClassName if using one of the %Trace Samplers (e.g. 'AlwaysOnSampler' or 'TraceIdRatioBasedSampler').

    Property Inventory

    Method Inventory

    Properties

    property localParentNotSampled as AbstractSampler;
    Sampler for Parent Remote = 0 and Sampled = 0
    Property methods: localParentNotSampledGet(), localParentNotSampledGetSwizzled(), localParentNotSampledIsValid(), localParentNotSampledNewObject(), localParentNotSampledSet()
    property localParentSampled as AbstractSampler;
    Sampler for Parent Remote = 0 and Sampled = 1
    Property methods: localParentSampledGet(), localParentSampledGetSwizzled(), localParentSampledIsValid(), localParentSampledNewObject(), localParentSampledSet()
    property remoteParentNotSampled as AbstractSampler;
    Sampler for Parent Remote = 1 and Sampled = 0
    Property methods: remoteParentNotSampledGet(), remoteParentNotSampledGetSwizzled(), remoteParentNotSampledIsValid(), remoteParentNotSampledNewObject(), remoteParentNotSampledSet()
    property remoteParentSampled as AbstractSampler;
    Sampler for Parent Remote = 1 and Sampled = 1
    Property methods: remoteParentSampledGet(), remoteParentSampledGetSwizzled(), remoteParentSampledIsValid(), remoteParentSampledNewObject(), remoteParentSampledSet()
    property root as AbstractSampler;
    Sampler for root Spans (no Parent)
    Property methods: rootGet(), rootGetSwizzled(), rootIsValid(), rootNewObject(), rootSet()

    Methods

    method %OnNew(Parameters As %List) as %Status
    Parameters is a $List of ClassNames (or short ClassNames if using %Trace) of Samplers and their Parameters, to be called by the ParentBasedSampler. The Parameters for the Sampler Class are specified using an embedded $List. The format is:
    $List(Sampler1,$List(Param1),Sampler2,$List(Param2))
      set Parameters = $lb("TraceIdRatioBasedSampler",$lb(".001"),"AlwaysOnSampler","","AlwaysOffSampler","")
      
    There are five possible delegated Samplers, but only the first ('root') is Required. In order in the $List, these Samplers are:
    1. root - Sampler called for spans with no parent (root spans)
    2. remoteParentSampled (default: AlwaysOnSampler)
    3. remoteParentNotSampler (default: AlwaysOffSampler)
    4. localParentSampled (default: AlwaysOnSampler)
    5. localParentNotSampled (default: AlwaysOffSampler)
    method GetDescription() as %String
    Returns the sampler name or short description. This may be displayed on debug pages or in logs. Example: 'TraceIdRatioBased{0.000100}'
    method ShouldSample(Context As %Trace.SpanContext, TraceId As %String, Name As %String, SpanKind As %String, ByRef Attributes As %String) as %Trace.SamplingResult
    Returns the sampling Decision for a Span to be created and recorded. 'Attributes' should be passed by reference as an array, e.g. Attribute("key")="value".

    Inherited Members

    Inherited Methods

  • FeedbackOpens in a new tab