Class: Twirl::Instrumentation::StatsdSubscriber

Inherits:
Subscriber
  • Object
show all
Defined in:
lib/twirl/instrumentation/statsd_subscriber.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Subscriber

call, #initialize, #update

Constructor Details

This class inherits a constructor from Twirl::Instrumentation::Subscriber

Class Attribute Details

.clientObject

Returns the value of attribute client.



12
13
14
# File 'lib/twirl/instrumentation/statsd_subscriber.rb', line 12

def client
  @client
end

Instance Method Details

#update_counter(metric, value = 1) ⇒ Object



21
22
23
24
25
# File 'lib/twirl/instrumentation/statsd_subscriber.rb', line 21

def update_counter(metric, value = 1)
  if self.class.client
    self.class.client.increment metric, value
  end
end

#update_timer(metric) ⇒ Object



15
16
17
18
19
# File 'lib/twirl/instrumentation/statsd_subscriber.rb', line 15

def update_timer(metric)
  if self.class.client
    self.class.client.timing metric, (@duration * 1_000).round
  end
end