Module: Bugwatch::DbTracker
- Defined in:
- lib/bugwatch/db_tracker.rb
Constant Summary collapse
- THREAD_KEY =
:bugwatch_db_tracker- IGNORED_NAMES =
%w[SCHEMA EXPLAIN].freeze
- IGNORED_SQL_PATTERNS =
/\A\s*(BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE SAVEPOINT)/i- CALLER_FILTER =
%r{/(active_record|bugwatch|ruby/gems)/}
Class Method Summary collapse
Class Method Details
.clear ⇒ Object
34 35 36 |
# File 'lib/bugwatch/db_tracker.rb', line 34 def clear Thread.current[THREAD_KEY] = nil end |
.finish_request ⇒ Object
28 29 30 31 32 |
# File 'lib/bugwatch/db_tracker.rb', line 28 def finish_request state = Thread.current[THREAD_KEY] Thread.current[THREAD_KEY] = nil state end |
.start_request(collecting:) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/bugwatch/db_tracker.rb', line 20 def start_request(collecting:) Thread.current[THREAD_KEY] = { queries: [], total_db_ms: 0.0, collecting: collecting } end |
.subscribe! ⇒ Object
13 14 15 16 17 18 |
# File 'lib/bugwatch/db_tracker.rb', line 13 def subscribe! ActiveSupport::Notifications.subscribe("sql.active_record") do |*args| event = ActiveSupport::Notifications::Event.new(*args) handle_event(event) end end |