module AppPerfRpm::Utils
Public Class Methods
log_source_and_backtrace(span, instrument)
click to toggle source
# File lib/app_perf_rpm/utils.rb, line 29 def self.log_source_and_backtrace(span, instrument) config = ::AppPerfRpm.config.instrumentation[instrument] || {} if kind = config[:backtrace] backtrace = AppPerfRpm::Backtrace.backtrace(kind: kind) if backtrace.length > 0 span.log(event: "backtrace", stack: backtrace) end end if config[:source] source = AppPerfRpm::Backtrace.source_extract if source.length > 0 span.log(event: "source", stack: source) end end end
Public Instance Methods
connection_config()
click to toggle source
# File lib/app_perf_rpm/utils.rb, line 11 def connection_config @connection_config ||= if ::ActiveRecord::VERSION::MAJOR == 2 || (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR < 1) ActiveRecord::Base.connection.instance_variable_get(:@config) else ::ActiveRecord::Base.connection_config end end
format_redis(command)
click to toggle source
# File lib/app_perf_rpm/utils.rb, line 19 def format_redis(command) command.is_a?(Symbol) ? command.to_s.upcase : command.to_s rescue StandardError => e "?" end
format_redis_command(command)
click to toggle source
# File lib/app_perf_rpm/utils.rb, line 25 def format_redis_command(command) command.map { |x| format_redis(x) }.join(' ') end
sanitize_sql(sql, adapter)
click to toggle source
# File lib/app_perf_rpm/utils.rb, line 7 def sanitize_sql(sql, adapter) sql.gsub(REGEXP, '?') end