Class: Seismograph::Sensor

Inherits:
Object
  • Object
show all
Includes:
Parameterize
Defined in:
lib/seismograph/sensor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ Sensor

Returns a new instance of Sensor.



10
11
12
# File 'lib/seismograph/sensor.rb', line 10

def initialize(namespace)
  @namespace = namespace
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



8
9
10
# File 'lib/seismograph/sensor.rb', line 8

def namespace
  @namespace
end

Instance Method Details

#benchmark(description, params = {}, &block) ⇒ Object



32
33
34
35
36
# File 'lib/seismograph/sensor.rb', line 32

def benchmark(description, params = {}, &block)
  with_success_and_failure(description, params) do
    Gateway.time(stat(description), gateway_params(params), &block)
  end
end

#count(description, amount, params = {}, &block) ⇒ Object



14
15
16
# File 'lib/seismograph/sensor.rb', line 14

def count(description, amount, params = {}, &block)
  track(description, amount, params, &block)
end

#decrement(description, params = {}) ⇒ Object



22
23
24
# File 'lib/seismograph/sensor.rb', line 22

def decrement(description, params = {})
  Gateway.decrement(stat(description), gateway_params(params))
end

#gauge(description, value, params = {}) ⇒ Object



38
39
40
# File 'lib/seismograph/sensor.rb', line 38

def gauge(description, value, params = {})
  Gateway.gauge(stat(description), value, gateway_params(params))
end

#increment(description, params = {}) ⇒ Object



18
19
20
# File 'lib/seismograph/sensor.rb', line 18

def increment(description, params = {})
  Gateway.increment(stat(description), gateway_params(params))
end

#timing(description, duration, params = {}) ⇒ Object

Record the time (in ms) when the code has already been executed. Useful for ActiveSupport::Instrumentation event.duration (which is already in ms)



28
29
30
# File 'lib/seismograph/sensor.rb', line 28

def timing(description, duration, params = {})
  Gateway.timing(stat(description), duration, gateway_params(params))
end