Class: NewRelic::Agent::Sampler

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/sampler.rb

Overview

A Sampler is used to capture meaningful metrics in a background thread periodically. They will either be invoked once a minute just before the data is sent to the agent (default) or every 10 seconds, when #use_harvest_sampler? returns false.

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.

Defined Under Namespace

Classes: Unsupported

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Sampler

Returns a new instance of Sampler.



37
38
39
# File 'lib/new_relic/agent/sampler.rb', line 37

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/new_relic/agent/sampler.rb', line 15

def id
  @id
end

#stats_engineObject

Returns the value of attribute stats_engine.



14
15
16
# File 'lib/new_relic/agent/sampler.rb', line 14

def stats_engine
  @stats_engine
end

Class Method Details

.inherited(subclass) ⇒ Object



18
19
20
# File 'lib/new_relic/agent/sampler.rb', line 18

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

.sampler_classesObject



33
34
35
# File 'lib/new_relic/agent/sampler.rb', line 33

def self.sampler_classes
  @sampler_classes
end

.supported_on_this_platform?Boolean

Override with check. Called before instantiating.

Returns:

  • (Boolean)


23
24
25
# File 'lib/new_relic/agent/sampler.rb', line 23

def self.supported_on_this_platform?
  true
end

.use_harvest_sampler?Boolean

Override to use the periodic sampler instead of running the sampler on the minute during harvests.

Returns:

  • (Boolean)


29
30
31
# File 'lib/new_relic/agent/sampler.rb', line 29

def self.use_harvest_sampler?
  true
end

Instance Method Details

#pollObject



41
42
43
# File 'lib/new_relic/agent/sampler.rb', line 41

def poll
  raise "Implement in the subclass"
end