Sha256: 67bcbf4a6ec16b5a010fcab9baf125352eb5d648b83708a84e78edd1cf62e1e6

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require "opentelemetry/sdk"
require_relative "./condition"

module Aspecto
  # Aspecto OpenTelemetry Distro
  module OpenTelemetry
    module Sampler
      # Single rule for sampling
      class SamplingRule
        def initialize(rule_config)
          @id = rule_config["_id"]
          @sampler = ::OpenTelemetry::SDK::Trace::Samplers.trace_id_ratio_based(rule_config["samplingRate"])
          @conditions = rule_config["conditions"].map { |condition_config| Condition.new condition_config }
        end

        attr_reader :sampler

        def satisfied?(attributes, span_name)
          @conditions.all? { |condition| condition.satisfied?(attributes, span_name) }
        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/sampling_rule.rb