Sha256: c8bf8dd082652717662503ac020690b68915baf235b2e587db037b527c37dae7

Contents?: true

Size: 1.22 KB

Versions: 17

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

require 'ting_yun/agent'

module TingYun
  module Agent
    module Collector
      class Sampler

        class Unsupported < StandardError;  end

        attr_reader :id
        @sampler_classes = []

        def self.named(new_name)
          @name = new_name
        end

        def self.name
          @name
        end

        def self.inherited(subclass)
          @sampler_classes << subclass
        end

        # Override with check.  Called before instantiating.
        def self.supported_on_this_platform?
          true
        end

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

        def self.sampler_classes
          @sampler_classes
        end

        # The ID passed in here is unused by our code, but is preserved in case
        # we have clients who are defining their own subclasses of this class, and
        # expecting to be able to call super with an ID.
        def initialize(id=nil)
          @id = id || self.class.name
        end

        def poll
          raise "Implement in the subclass"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tingyun_rpm-3.2.0 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.6.1 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.5.0 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.4.2 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.4.1 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.3.1 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.3.0 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.2.0 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.4.2 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.4.1 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.4 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.3 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.2 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.1 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.1.0 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.0.7 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb
tingyun_rpm-1.0.6 lib/ting_yun/agent/collector/middle_ware_collector/sampler.rb