Initial Commit
Co-authored-by: Subin <subinthattaparambil@gmail.com> Co-authored-by: Manoj <manojmj92@gmail.com> Co-authored-by: Nithin <webofnithin@gmail.com>
This commit is contained in:
30
config/initializers/sentry.rb
Normal file
30
config/initializers/sentry.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
Raven.configure do |config|
|
||||
config.dsn = ENV['SENTRY_DSN']
|
||||
config.environments = ['staging', 'production']
|
||||
end
|
||||
|
||||
module QueryTrace
|
||||
def self.enable!
|
||||
::ActiveRecord::LogSubscriber.send(:include, self)
|
||||
end
|
||||
|
||||
def self.append_features(klass)
|
||||
super
|
||||
klass.class_eval do
|
||||
unless method_defined?(:log_info_without_trace)
|
||||
alias_method :log_info_without_trace, :sql
|
||||
alias_method :sql, :log_info_with_trace
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def log_info_with_trace(event)
|
||||
log_info_without_trace(event)
|
||||
trace_log = Rails.backtrace_cleaner.clean(caller).first
|
||||
if trace_log && event.payload[:name] != 'SCHEMA'
|
||||
logger.debug(" \\_ \e[33mCalled from:\e[0m " + trace_log)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
QueryTrace.enable! unless Rails.env.production?
|
||||
Reference in New Issue
Block a user