Sha256: 99cc17e0eb021820c688640372ae029d083e6d472be2e51a57c5133713ec7b41
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 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 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.delete(event.request_id) || {} # Finish the event in the extension. Appsignal::Extension.finish_event( transaction.transaction_index, 'query.mongodb', "#{event.command_name.to_s} | #{event.database_name} | #{result}", JSON.generate(command), 0 ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
appsignal-1.0.5.beta.2 | lib/appsignal/integrations/mongo_ruby_driver.rb |
appsignal-1.0.5.beta.1 | lib/appsignal/integrations/mongo_ruby_driver.rb |