Class: OpenTelemetry::Exporters::Datadog::DatadogProbabilitySampler
- Inherits:
-
SDK::Trace::Samplers::ProbabilitySampler
- Object
- SDK::Trace::Samplers::ProbabilitySampler
- OpenTelemetry::Exporters::Datadog::DatadogProbabilitySampler
- Defined in:
- lib/opentelemetry/exporters/datadog/datadog_probability_sampler.rb
Overview
Implements sampling based on a probability but records all spans regardless.
Constant Summary collapse
- DEFAULT =
new(1.0, ignore_parent: false, apply_to_remote_parent: :root_spans_and_remote_parent, apply_to_all_spans: :root_spans_and_remote_parent)
Class Method Summary collapse
-
.default_with_probability(probability = 1.0) ⇒ Object
Returns a new sampler.
Instance Method Summary collapse
-
#should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean
private
See Samplers.
Class Method Details
.default_with_probability(probability = 1.0) ⇒ Object
Returns a new sampler. The probability of sampling a trace is equal to that of the specified probability.
40 41 42 43 44 45 46 47 |
# File 'lib/opentelemetry/exporters/datadog/datadog_probability_sampler.rb', line 40 def self.default_with_probability(probability = 1.0) raise ArgumentError, 'probability must be in range [0.0, 1.0]' unless (0.0..1.0).include?(probability) new(probability, ignore_parent: false, apply_to_remote_parent: :root_spans_and_remote_parent, apply_to_all_spans: :root_spans_and_remote_parent) end |
Instance Method Details
#should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
See Samplers.
25 26 27 28 29 30 31 32 33 |
# File 'lib/opentelemetry/exporters/datadog/datadog_probability_sampler.rb', line 25 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) # Ignored for sampling decision: links, name, kind, attributes. if sample?(trace_id, parent_context) RECORD_AND_SAMPLED else RECORD end end |