Module: Raygun::Apm::Hooks::MongoDB

Defined in:
lib/raygun/apm/hooks/mongodb.rb

Instance Method Summary collapse

Instance Method Details

#do_execute(connection, client, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/raygun/apm/hooks/mongodb.rb', line 7

def do_execute(connection, client, options = {})
  result = nil
  if tracer = Raygun::Apm::Tracer.instance
    started = tracer.now
    result = super
    ended = tracer.now
    event = raygun_apm_sql_event
    event[:pid] = Process.pid
    event[:query] = raygun_format_query(connection)
    event[:provider] = "mongodb"
    event[:host] = connection.address.to_s
    event[:database] = client.database.name
    event[:duration] = ended - started
    event[:timestamp] = started
    event[:tid] = tracer.get_thread_id(Thread.current)
    tracer.emit(event)
    result
  else
    super
  end
end