Sha256: 6d2f8506d3f865eaf324fe418e3f13404ff2cc36a2ac5fb65c052e829253618b

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Aspecto
  # Aspecto OpenTelemetry Distro
  module OpenTelemetry
    # Sampling logic for aspecto otel distribution
    module Sampler
      extend self

      def meets_operator?(operator, expected, actual) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
        expected_lower = expected&.downcase
        actual_lower = actual&.downcase
        case operator
        when :eq
          expected_lower == actual_lower
        when :ne
          expected_lower != actual_lower
        when :starts_with
          actual_lower.start_with?(expected_lower)
        when :ends_with
          actual_lower.end_with?(expected_lower)
        when :contains
          actual_lower.include?(expected_lower)
        when :not_contains
          !actual_lower.include?(expected_lower)
        when :matches
          Regexp.new(expected_lower).match(actual_lower)
        when :defined
          !actual.nil?
        when :undefined
          actual.nil?
        when :any
          true
        else
          false
        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/utils.rb