Class: Camayoc::Handlers::Statsd

Inherits:
Object
  • Object
show all
Includes:
ThreadSafety
Defined in:
lib/camayoc/handlers/statsd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ThreadSafety

#synchronize, #thread_safe=, #thread_safe?

Constructor Details

#initialize(options = {}) ⇒ Statsd

Returns a new instance of Statsd.



13
14
15
16
17
18
19
# File 'lib/camayoc/handlers/statsd.rb', line 13

def initialize(options={})
  self.namespace = options[:namespace]
  @host = options[:host]
  @port = options[:port]
  @socket = UDPSocket.new
  self.thread_safe = Camayoc.thread_safe?
end

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



11
12
13
# File 'lib/camayoc/handlers/statsd.rb', line 11

def namespace
  @namespace
end

Instance Method Details

#count(event) ⇒ Object



21
22
23
# File 'lib/camayoc/handlers/statsd.rb', line 21

def count(event)
  send(event.ns_stat,event.value,'c',event.options[:sample_rate]||1) 
end

#timing(event) ⇒ Object



25
26
27
# File 'lib/camayoc/handlers/statsd.rb', line 25

def timing(event)
  send(event.ns_stat, event.value, 'ms', event.options[:sample_rate]||1) 
end