Class: Aspecto::OpenTelemetry::Sampler::SamplingRule
- Inherits:
-
Object
- Object
- Aspecto::OpenTelemetry::Sampler::SamplingRule
- Defined in:
- lib/aspecto/opentelemetry/sampler/sampling_rule.rb
Overview
Single rule for sampling
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#sampler ⇒ Object
readonly
Returns the value of attribute sampler.
Instance Method Summary collapse
-
#initialize(rule_config) ⇒ SamplingRule
constructor
A new instance of SamplingRule.
- #satisfies?(attributes, span_name) ⇒ Boolean
Constructor Details
#initialize(rule_config) ⇒ SamplingRule
Returns a new instance of SamplingRule.
12 13 14 15 16 17 |
# File 'lib/aspecto/opentelemetry/sampler/sampling_rule.rb', line 12 def initialize(rule_config) @id = rule_config["_id"] @sampler = ::OpenTelemetry::SDK::Trace::Samplers.trace_id_ratio_based(rule_config["samplingRate"]) @conditions = rule_config["conditions"].map { |condition_config| Condition.new condition_config } @context = rule_config["context"] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
19 20 21 |
# File 'lib/aspecto/opentelemetry/sampler/sampling_rule.rb', line 19 def context @context end |
#sampler ⇒ Object (readonly)
Returns the value of attribute sampler.
19 20 21 |
# File 'lib/aspecto/opentelemetry/sampler/sampling_rule.rb', line 19 def sampler @sampler end |
Instance Method Details
#satisfies?(attributes, span_name) ⇒ Boolean
21 22 23 |
# File 'lib/aspecto/opentelemetry/sampler/sampling_rule.rb', line 21 def satisfies?(attributes, span_name) @conditions.all? { |condition| condition.satisfies?(attributes, span_name) } end |