Sha256: bd57fbd92c837595b7a44b30b7c1956274f20399873e8dfc890f2b8873831c09

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

# frozen_string_literal: true

require_relative "./utils"

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"]
          @from = condition_config["from"]&.to_sym
          @key = condition_config["key"]
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aspecto-opentelemetry-0.1.1 lib/aspecto/opentelemetry/sampler/condition.rb