Class: Trashed::NewRelic::Sampler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(meter, options = {}) ⇒ Sampler

Returns a new instance of Sampler.



10
11
12
13
14
# File 'lib/trashed/new_relic.rb', line 10

def initialize(meter, options = {})
  @meter  = meter
  @label  = options[:label] || 'Custom/%s'
  @statsd = options[:statsd]
end

Instance Attribute Details

#stats_engineObject

Returns the value of attribute stats_engine.



8
9
10
# File 'lib/trashed/new_relic.rb', line 8

def stats_engine
  @stats_engine
end

Instance Method Details

#pollObject



16
17
18
19
# File 'lib/trashed/new_relic.rb', line 16

def poll
  record @meter.count
  record @meter.gauge
end

#record(data) ⇒ Object



21
22
23
24
25
26
# File 'lib/trashed/new_relic.rb', line 21

def record(data)
  data.each do |name, value|
    record_newrelic name, value
    record_statsd   name, value if @statsd
  end
end