Sha256: a00d92ba54111337dc3a65508e2aa7e29313d748b3a2b0d30da510c654267d05
Contents?: true
Size: 1.68 KB
Versions: 14
Compression:
Stored size: 1.68 KB
Contents
module Appsignal class Hooks class MongoMonitorSubscriber # Called by Mongo::Monitor when query starts def started(event) transaction = Appsignal::Transaction.current return if transaction.nil_transaction? return if transaction.paused? # Format the command command = Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter .format(event.command_name, event.command) # Store the query on the transaction, we need it when the event finishes store = transaction.store('mongo_driver') store[event.request_id] = command # Start this event transaction.start_event end # Called by Mongo::Monitor when query succeeds def succeeded(event) # Finish the event as succeeded finish('SUCCEEDED', event) end # Called by Mongo::Monitor when query fails def failed(event) # Finish the event as failed finish('FAILED', event) end # Finishes the event in the AppSignal extension def finish(result, event) transaction = Appsignal::Transaction.current return if transaction.nil_transaction? return if transaction.paused? # Get the query from the transaction store store = transaction.store('mongo_driver') command = store.delete(event.request_id) || {} # Finish the event in the extension. transaction.finish_event( 'query.mongodb', "#{event.command_name.to_s} | #{event.database_name} | #{result}", Appsignal::Utils.json_generate(command), Appsignal::EventFormatter::DEFAULT ) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems