Class: Rack::StatsdBatch::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/statsd_batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecorder

Returns a new instance of Recorder.



22
23
24
# File 'lib/rack/statsd_batch.rb', line 22

def initialize
  @data = []
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



20
21
22
# File 'lib/rack/statsd_batch.rb', line 20

def data
  @data
end

Instance Method Details

#count(key, diff) ⇒ Object



26
27
28
# File 'lib/rack/statsd_batch.rb', line 26

def count key, diff
  @data << "#{key}:#{diff}|c"
end

#gauge(key, value) ⇒ Object



34
35
36
# File 'lib/rack/statsd_batch.rb', line 34

def gauge key, value
  @data << "#{key}:#{value}|g"
end

#gauge_diff(key, diff) ⇒ Object



38
39
40
41
42
# File 'lib/rack/statsd_batch.rb', line 38

def gauge_diff key, diff
  value = "#{diff}"
  value = "+#{value}" if diff > 0
  @data << "#{key}:#{value}|g"
end

#publish(host, port, mtu) ⇒ Object



48
49
50
51
52
# File 'lib/rack/statsd_batch.rb', line 48

def publish host, port, mtu
  return if @data.empty?
  c = connection(host, port)
  build_packets(mtu).each {|p| c.send(p) }
end

#sets(key, set_entry) ⇒ Object



44
45
46
# File 'lib/rack/statsd_batch.rb', line 44

def sets key, set_entry
  @data << "#{key}:#{set_entry}|s"
end

#timing(key, ms) ⇒ Object



30
31
32
# File 'lib/rack/statsd_batch.rb', line 30

def timing key, ms
  @data << "#{key}:#{ms}|ms"
end