Class: Thrifter::InstrumentedPool

Inherits:
ConnectionPool
  • Object
show all
Defined in:
lib/thrifter/instrumented_pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = { }, &block) ⇒ InstrumentedPool

Returns a new instance of InstrumentedPool.



5
6
7
8
# File 'lib/thrifter/instrumented_pool.rb', line 5

def initialize(options = { }, &block)
  super(options, &block)
  @statsd = options.fetch(:statsd)
end

Instance Attribute Details

#statsdObject (readonly)

Returns the value of attribute statsd.



3
4
5
# File 'lib/thrifter/instrumented_pool.rb', line 3

def statsd
  @statsd
end

Instance Method Details

#checkin(*args) ⇒ Object



23
24
25
26
27
28
# File 'lib/thrifter/instrumented_pool.rb', line 23

def checkin(*args)
  super.tap do
    statsd.increment('thread_pool.checkin')
    statsd.gauge('thread_pool.in_use', in_use)
  end
end

#checkout(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thrifter/instrumented_pool.rb', line 10

def checkout(*args)
  statsd.gauge('thread_pool.size', @size)
  statsd.time('thread_pool.latency') do
    super.tap do |conn|
      statsd.increment('thread_pool.checkout')
      statsd.gauge('thread_pool.in_use', in_use)
    end
  end
rescue Timeout::Error => ex
  statsd.increment('thread_pool.timeout')
  raise ex
end