Class: Vmpooler::PoolManager::GenericConnectionPool
- Inherits:
-
ConnectionPool
- Object
- ConnectionPool
- Vmpooler::PoolManager::GenericConnectionPool
- Defined in:
- lib/vmpooler/generic_connection_pool.rb
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ GenericConnectionPool
constructor
Extend the ConnectionPool class with instrumentation github.com/mperham/connection_pool/blob/master/lib/connection_pool.rb.
-
#with_metrics(options = {}) ⇒ Object
jruby 1.7.x.
Constructor Details
#initialize(options = {}, &block) ⇒ GenericConnectionPool
Extend the ConnectionPool class with instrumentation github.com/mperham/connection_pool/blob/master/lib/connection_pool.rb
9 10 11 12 13 14 |
# File 'lib/vmpooler/generic_connection_pool.rb', line 9 def initialize( = {}, &block) super(, &block) @metrics = [:metrics] @metric_prefix = [:metric_prefix] @metric_prefix = 'connectionpool' if @metric_prefix.nil? || @metric_prefix == '' end |
Instance Method Details
#with_metrics(options = {}) ⇒ Object
jruby 1.7.x
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vmpooler/generic_connection_pool.rb', line 18 def with_metrics( = {}) Thread.handle_interrupt(Exception => :never) do start = Time.now conn = checkout() timespan_ms = ((Time.now - start) * 1000).to_i @metrics.gauge(@metric_prefix + '.available', @available.length) unless @metrics.nil? @metrics.timing(@metric_prefix + '.waited', timespan_ms) unless @metrics.nil? begin Thread.handle_interrupt(Exception => :immediate) do yield conn end ensure checkin @metrics.gauge(@metric_prefix + '.available', @available.length) unless @metrics.nil? end end end |