Sha256: f525d5236a4818be20bb74cbfaa1fb0ba5c2fc9e1748814bcda61f3e68708e2c
Contents?: true
Size: 1.57 KB
Versions: 13
Compression:
Stored size: 1.57 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? # Store the query on the transaction, we need it when the event finishes store = transaction.store('mongo_driver') store[event.request_id] = Appsignal::Utils.sanitize(event.command) # Start this event Appsignal::Extension.start_event(transaction.transaction_index) 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[event.request_id].inspect # Finish the event in the extension. Appsignal::Extension.finish_event( transaction.transaction_index, 'query.mongodb', event.command_name.to_s, %Q(#{event.database_name} | #{result} | #{command}) ) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems