class NewRelic::Agent::Database::ConnectionManager
Public Instance Methods
close_connections()
click to toggle source
Closes all the connections in the internal connection cache
# File lib/new_relic/agent/database.rb, line 159 def close_connections @connections ||= {} @connections.values.each do |connection| begin connection.disconnect! rescue end end @connections = {} end
get_connection(config) { |config| ... }
click to toggle source
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
# File lib/new_relic/agent/database.rb, line 143 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