Module: Metrics::StatsdApi

Included in:
Metrics, Grouping
Defined in:
lib/metrics/statsd_api.rb

Overview

This adds a statsd compatible api that delegates back to #instrument

Instance Method Summary collapse

Instance Method Details

#count(stat, count, options = {}) ⇒ Object



12
13
14
# File 'lib/metrics/statsd_api.rb', line 12

def count(stat, count, options = {})
  instrument stat, count, options.merge(type: 'count')
end

#decrement(stat, options = {}) ⇒ Object



8
9
10
# File 'lib/metrics/statsd_api.rb', line 8

def decrement(stat, options = {})
  instrument stat, -1, options.merge(type: 'count')
end

#gauge(stat, value, options = {}) ⇒ Object



16
17
18
# File 'lib/metrics/statsd_api.rb', line 16

def gauge(stat, value, options = {})
  instrument stat, value, options.merge(type: 'measure')
end

#histogram(stat, value, options = {}) ⇒ Object



20
21
22
# File 'lib/metrics/statsd_api.rb', line 20

def histogram(stat, value, options = {})
  instrument stat, value, options.merge(type: 'histogram')
end

#increment(stat, options = {}) ⇒ Object



4
5
6
# File 'lib/metrics/statsd_api.rb', line 4

def increment(stat, options = {})
  instrument stat, 1, options.merge(type: 'count')
end

#time(stat, options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/metrics/statsd_api.rb', line 28

def time(stat, options = {})
  instrument stat, options do
    yield
  end
end

#timing(stat, ms, options = {}) ⇒ Object



24
25
26
# File 'lib/metrics/statsd_api.rb', line 24

def timing(stat, ms, options = {})
  instrument stat, ms, options.merge(type: 'measure', units: 'ms')
end