module NewRelic::Agent::Instrumentation::ActiveRecordHelper::InstanceIdentification
Constants
- DATASTORE_DEFAULT_PORTS
- DEFAULT
- LOCALHOST
- PRODUCT_SYMBOLS
- SUPPORTED_ADAPTERS
- UNKNOWN
Public Instance Methods
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 241 def adapter_from_config(config) bare_name = NewRelic::Agent::Instrumentation::ActiveRecordHelper.bare_adapter_name(config[:adapter]) PRODUCT_SYMBOLS[bare_name] end
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 246 def host(config) return UNKNOWN unless config configured_value = config[:host] adapter = adapter_from_config(config) if configured_value.nil? || postgres_unix_domain_socket_case?(configured_value, adapter) LOCALHOST elsif configured_value.empty? UNKNOWN else configured_value end rescue => e NewRelic::Agent.logger.debug("Failed to retrieve ActiveRecord host: #{e}") UNKNOWN end
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 265 def port_path_or_id(config) return UNKNOWN unless config adapter = adapter_from_config(config) if config[:socket] config[:socket].empty? ? UNKNOWN : config[:socket] elsif postgres_unix_domain_socket_case?(config[:host], adapter) || mysql_default_case?(config, adapter) DEFAULT elsif config[:port].nil? DATASTORE_DEFAULT_PORTS[adapter] || DEFAULT elsif config[:port].is_a?(Integer) || config[:port].to_i != 0 config[:port].to_s else UNKNOWN end rescue => e NewRelic::Agent.logger.debug("Failed to retrieve ActiveRecord port_path_or_id: #{e}") UNKNOWN end
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 287 def supported_adapter?(config) config && SUPPORTED_ADAPTERS.include?(adapter_from_config(config)) end
Private Instance Methods
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 297 def mysql_default_case?(config, adapter) (adapter == :mysql2 || adapter == :mysql) && Hostname.local?(config[:host]) && !config[:port] end
Source
# File lib/new_relic/agent/instrumentation/active_record_helper.rb, line 293 def postgres_unix_domain_socket_case?(host, adapter) adapter == :postgres && host && host.start_with?(NewRelic::SLASH) end