Sha256: ec29ce8a0686f4c4b2e4ebbf67ff301b5c1c910d79a865f2f34d1640adae8c6c

Contents?: true

Size: 819 Bytes

Versions: 12

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require_relative "./operator"

module Aspecto
  # Aspecto OpenTelemetry Distro
  module OpenTelemetry
    module Sampler
      # Aspecto's sampling rule condition
      class Condition
        def initialize(condition_config)
          @operator = Operator.new condition_config["comparison"], condition_config["value"]
          @from = condition_config["from"]&.to_sym
          @key = condition_config["key"]
        end

        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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
aspecto-opentelemetry-0.2.0 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.2.0.rc0 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.10 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.9 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.8 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.7 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.7.rc0 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.6 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.5 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.4 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.3 lib/aspecto/opentelemetry/sampler/condition.rb
aspecto-opentelemetry-0.1.2 lib/aspecto/opentelemetry/sampler/condition.rb