Class: NewRelic::Agent::Database::ConnectionManager
- Inherits:
-
Object
- Object
- NewRelic::Agent::Database::ConnectionManager
- Includes:
- Singleton
- Defined in:
- lib/new_relic/agent/database.rb
Instance Method Summary collapse
-
#close_connections ⇒ Object
Closes all the connections in the internal connection cache.
-
#get_connection(config, &connector) ⇒ Object
Returns a cached connection for a given ActiveRecord configuration - these are stored or reopened as needed, and if we cannot get one, we ignore it and move on without explaining the sql.
Instance Method Details
#close_connections ⇒ Object
Closes all the connections in the internal connection cache
218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/new_relic/agent/database.rb', line 218 def close_connections @connections ||= {} @connections.values.each do |connection| begin connection.disconnect! rescue end end @connections = {} end |
#get_connection(config, &connector) ⇒ Object
Returns a cached connection for a given ActiveRecord configuration - these are stored or reopened as needed, and if we cannot get one, we ignore it and move on without explaining the sql
202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/new_relic/agent/database.rb', line 202 def get_connection(config, &connector) @connections ||= {} connection = @connections[config] return connection if connection begin @connections[config] = yield(config) rescue => e ::NewRelic::Agent.logger.error('Caught exception trying to get connection to DB for explain.', e) nil end end |