Sha256: 66844e59896ad85de93ff866fa3b986f61b6a2f0b2facc84a8a6d05a37c7ddf7

Contents?: true

Size: 797 Bytes

Versions: 12

Compression:

Stored size: 797 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 }
          @context = rule_config["context"]
        end

        attr_reader :sampler, :context

        def satisfies?(attributes, span_name)
          @conditions.all? { |condition| condition.satisfies?(attributes, span_name) }
        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/sampling_rule.rb
aspecto-opentelemetry-0.2.0.rc0 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.10 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.9 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.8 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.7 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.7.rc0 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.6 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.5 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.4 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.3 lib/aspecto/opentelemetry/sampler/sampling_rule.rb
aspecto-opentelemetry-0.1.2 lib/aspecto/opentelemetry/sampler/sampling_rule.rb