Class: ActiveMeasure::Adapters::Statsd

Inherits:
Base
  • Object
show all
Defined in:
lib/active_measure/adapters/statsd.rb

Direct Known Subclasses

StatsdSocket, StatsdTagged

Constant Summary collapse

VALID_METRICS_TYPES =

c - counter g - gauge h - histogram ms - measure s - set d - distribution

%i[c g h ms s d].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Statsd

Returns a new instance of Statsd.



19
20
21
22
23
# File 'lib/active_measure/adapters/statsd.rb', line 19

def initialize(options = {})
  @host = options.fetch(:host, 'localhost')
  @port = options.fetch(:port, 8125)
  @client = options.fetch(:client)
end

Instance Method Details

#count(metric, value = nil, tags: {}, **_options) ⇒ Object



33
34
35
# File 'lib/active_measure/adapters/statsd.rb', line 33

def count(metric, value = nil, tags: {}, **_options)
  send_measure(:c, metric, value, tags)
end

#decrement(metric, value = nil, tags: {}, **_options) ⇒ Object



29
30
31
# File 'lib/active_measure/adapters/statsd.rb', line 29

def decrement(metric, value = nil, tags: {}, **_options)
  send_measure(:c, metric, -value, tags)
end

#dispatch_metric(metric) ⇒ Object



15
16
17
# File 'lib/active_measure/adapters/statsd.rb', line 15

def dispatch_metric(metric)
  connection.send(metric.to_s, 0)
end

#distribution(metric, value = nil, tags: {}, **_options) ⇒ Object



57
58
59
# File 'lib/active_measure/adapters/statsd.rb', line 57

def distribution(metric, value = nil, tags: {}, **_options)
  send_measure(:d, metric, value, tags)
end

#gauge(metric, value = nil, tags: {}, **_options) ⇒ Object



37
38
39
# File 'lib/active_measure/adapters/statsd.rb', line 37

def gauge(metric, value = nil, tags: {}, **_options)
  send_measure(:g, metric, value, tags)
end

#histogram(metric, value = nil, tags: {}, **_options) ⇒ Object



49
50
51
# File 'lib/active_measure/adapters/statsd.rb', line 49

def histogram(metric, value = nil, tags: {}, **_options)
  send_measure(:h, metric, value, tags)
end

#increment(metric, value = nil, tags: {}, **_options) ⇒ Object



25
26
27
# File 'lib/active_measure/adapters/statsd.rb', line 25

def increment(metric, value = nil, tags: {}, **_options)
  send_measure(:c, metric, value, tags)
end

#set(metric, value = nil, tags: {}, **_options) ⇒ Object



53
54
55
# File 'lib/active_measure/adapters/statsd.rb', line 53

def set(metric, value = nil, tags: {}, **_options)
  send_measure(:s, metric, value, tags)
end

#time(metric, value = nil, tags: {}, **_options) ⇒ Object



45
46
47
# File 'lib/active_measure/adapters/statsd.rb', line 45

def time(metric, value = nil, tags: {}, **_options)
  send_measure(:ms, metric, value, tags)
end

#timing(metric, value = nil, tags: {}, **_options) ⇒ Object



41
42
43
# File 'lib/active_measure/adapters/statsd.rb', line 41

def timing(metric, value = nil, tags: {}, **_options)
  send_measure(:ms, metric, value, tags)
end