Sha256: daab1d5a2d831f2c5bde718a1431536a7d5ced06f73a328d1d8f93f64b0de0b7

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

# encoding: utf-8

module OneApm
  module Agent
    class Sampler

      attr_reader :id

      @sampler_classes = []

      class << self

        def named(new_name)
          @name = new_name
        end

        def name
          @name
        end

        def inherited(subclass)
          @sampler_classes << subclass
        end

        def supported_on_this_platform?
          true
        end

        def enabled?
          if @name
            config_key = "disable_#{@name}_sampler"
            !(Agent.config[config_key])
          else
            true
          end
        end

        def sampler_classes
          @sampler_classes
        end

      end

      def initialize(id = nil)
        @id = id || self.class.name
      end

      def poll
        raise "Implement in the subclass"
      end

      class Unsupported < StandardError;  end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oneapm_rpm-1.1.2 lib/one_apm/agent/sampler.rb
oneapm_rpm-1.1.1 lib/one_apm/agent/sampler.rb
oneapm_rpm-1.1.0 lib/one_apm/agent/sampler.rb