lib/aspecto/opentelemetry/sampler/condition.rb in aspecto-opentelemetry-0.1.1 vs lib/aspecto/opentelemetry/sampler/condition.rb in aspecto-opentelemetry-0.1.2
- old
+ new
@@ -1,27 +1,26 @@
# frozen_string_literal: true
-require_relative "./utils"
+require_relative "./operator"
module Aspecto
# Aspecto OpenTelemetry Distro
module OpenTelemetry
module Sampler
# Aspecto's sampling rule condition
class Condition
def initialize(condition_config)
- @comparison = condition_config["comparison"]&.to_sym
- @value = condition_config["value"]
+ @operator = Operator.new condition_config["comparison"], condition_config["value"]
@from = condition_config["from"]&.to_sym
@key = condition_config["key"]
end
- def satisfied?(attributes, span_name)
+ def satisfies?(attributes, span_name)
case @from
when :attribute
- Sampler.meets_operator?(@comparison, @value, attributes[@key]&.to_s)
+ @operator.satisfies? attributes&.[](@key)&.to_s
when :operation
- Sampler.meets_operator?(@comparison, @value, span_name)
+ @operator.satisfies? span_name
else
# Other "from" are not implemented for now
false
end
end