Method: Datadog::Tracing::Sampling::RuleSampler#sample!

Defined in:
lib/datadog/tracing/sampling/rule_sampler.rb

#sample!(trace) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/datadog/tracing/sampling/rule_sampler.rb', line 93

def sample!(trace)
  sampled = sample_trace(trace) do |t|
    @default_sampler.sample!(t).tap do
      # We want to make sure the trace is tagged with the agent-derived
      # service rate. Retrieve this from the rate by service sampler.
      # Only do this if it was set by a RateByServiceSampler.
      trace.agent_sample_rate = @default_sampler.sample_rate(trace) if @default_sampler.is_a?(RateByServiceSampler)
    end
  end

  trace.sampled = sampled
end