Sha256: 3611aa0fb69b20e5104d91e13a22b2f3494a7a604043fa859a79027b2a3662ce

Contents?: true

Size: 1.17 KB

Versions: 23

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
#
# A Sampler is used to capture meaningful metrics in a background thread
# periodically.  They will be invoked about once a minute, each time the agent
# sends data to New Relic's servers.
#
# Samplers can be added to New Relic by subclassing NewRelic::Agent::Sampler.
# Instances are created when the agent is enabled and installed.  Subclasses
# are registered for instantiation automatically.
module NewRelic
  module Agent
    class Sampler

      # Exception denotes a sampler is not available and it will not be registered.
      class Unsupported < StandardError;  end

      attr_reader :id
      @sampler_classes = []

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

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

      def self.sampler_classes
        @sampler_classes
      end

      def initialize(id)
        @id = id
      end

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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.3.111 lib/new_relic/agent/sampler.rb
newrelic_rpm-3.6.3.106 lib/new_relic/agent/sampler.rb
newrelic_rpm-3.6.3.105.beta lib/new_relic/agent/sampler.rb