Class: NoBrainer::Profiler::SlowQueries

Inherits:
Logger
  • Object
show all
Defined in:
lib/no_brainer/profiler/slow_queries.rb

Instance Method Summary collapse

Instance Method Details

#on_query(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/no_brainer/profiler/slow_queries.rb', line 6

def on_query(env)
  return unless NoBrainer::Config.on_slow_query

  query_duration = (env[:duration] * 1000.0).round(1)

  return unless query_duration > NoBrainer::Config.long_query_time

  message = build_message(env)
  NoBrainer::Config.on_slow_query.call(message)
end