Module: NewRelic::Agent::Instrumentation::ActiveRecordHelper::InstanceIdentification
- Extended by:
- InstanceIdentification
- Included in:
- InstanceIdentification
- Defined in:
- lib/new_relic/agent/instrumentation/active_record_helper.rb
Constant Summary collapse
- PRODUCT_SYMBOLS =
{ 'mysql' => :mysql, 'mysql2' => :mysql, 'jdbcmysql' => :mysql, 'postgresql' => :postgres, 'jdbcpostgresql' => :postgres, 'postgis' => :postgres }.freeze
- DATASTORE_DEFAULT_PORTS =
{ :mysql => '3306', :postgres => '5432' }.freeze
- DEFAULT =
'default'.freeze
- UNKNOWN =
'unknown'.freeze
- LOCALHOST =
'localhost'.freeze
- SUPPORTED_ADAPTERS =
[:mysql, :postgres].freeze
Instance Method Summary collapse
- #adapter_from_config(config) ⇒ Object
- #host(config) ⇒ Object
- #port_path_or_id(config) ⇒ Object
- #supported_adapter?(config) ⇒ Boolean
Instance Method Details
#adapter_from_config(config) ⇒ Object
237 238 239 240 |
# File 'lib/new_relic/agent/instrumentation/active_record_helper.rb', line 237 def adapter_from_config(config) = NewRelic::Agent::Instrumentation::ActiveRecordHelper.(config[:adapter]) PRODUCT_SYMBOLS[] end |
#host(config) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/new_relic/agent/instrumentation/active_record_helper.rb', line 242 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 |
#port_path_or_id(config) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/new_relic/agent/instrumentation/active_record_helper.rb', line 261 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 |
#supported_adapter?(config) ⇒ Boolean
283 284 285 |
# File 'lib/new_relic/agent/instrumentation/active_record_helper.rb', line 283 def supported_adapter?(config) config && SUPPORTED_ADAPTERS.include?(adapter_from_config(config)) end |