Class: Aspecto::OpenTelemetry::Sampler::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/aspecto/opentelemetry/sampler/condition.rb

Overview

Aspecto’s sampling rule condition

Instance Method Summary collapse

Constructor Details

#initialize(condition_config) ⇒ Condition

Returns a new instance of Condition.



11
12
13
14
15
# File 'lib/aspecto/opentelemetry/sampler/condition.rb', line 11

def initialize(condition_config)
  @operator = Operator.new condition_config["comparison"], condition_config["value"]
  @from = condition_config["from"]&.to_sym
  @key = condition_config["key"]
end

Instance Method Details

#satisfies?(attributes, span_name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aspecto/opentelemetry/sampler/condition.rb', line 17

def satisfies?(attributes, span_name)
  case @from
  when :attribute
    @operator.satisfies? attributes&.[](@key)&.to_s
  when :operation
    @operator.satisfies? span_name
  else
    # Other "from" are not implemented for now
    false
  end
end