Class: Metrics::Drivers::DogStatsd

Inherits:
Statsd
  • Object
show all
Defined in:
lib/metrics/drivers/dog_statsd.rb

Instance Attribute Summary

Attributes inherited from Statsd

#client, #source_prefix, #template

Instance Method Summary collapse

Methods inherited from Statsd

#initialize, #write

Constructor Details

This class inherits a constructor from Metrics::Drivers::Statsd

Instance Method Details

#emit(instrumenter) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/metrics/drivers/dog_statsd.rb', line 4

def emit(instrumenter)
  name = name_for(instrumenter)
  value = instrumenter.value
  tags = formatted_tags(instrumenter.tags)

  case instrumenter.type
    when 'histogram'
      client.histogram(name, value, tags: tags)
    when 'measure', 'sample'
      if instrumenter.units == 'ms'
        client.timing(name, value, tags: tags)
      else
        client.gauge(name, value, tags: tags)
      end
    when 'count'
      client.count(name, value, tags: tags)
    else
      raise ArgumentError.new("unsupported instrumenter type for dogstatsd: '%s'" % instrumenter.type)
  end
end