Class: Appsignal::Hooks::MongoMonitorSubscriber Private
- Defined in:
- lib/appsignal/integrations/mongo_ruby_driver.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#failed(event) ⇒ Object
private
Called by Mongo::Monitor when query fails.
-
#finish(result, event) ⇒ Object
private
Finishes the event in the AppSignal extension.
-
#started(event) ⇒ Object
private
Called by Mongo::Monitor when query starts.
-
#succeeded(event) ⇒ Object
private
Called by Mongo::Monitor when query succeeds.
Instance Method Details
#failed(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Called by Mongo::Monitor when query fails
30 31 32 33 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 30 def failed(event) # Finish the event as failed finish("FAILED", event) end |
#finish(result, event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finishes the event in the AppSignal extension
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 36 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} | #{event.database_name} | #{result}", Appsignal::Utils.data_generate(command), Appsignal::EventFormatter::DEFAULT ) end |
#started(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Called by Mongo::Monitor when query starts
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 6 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 |
#succeeded(event) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Called by Mongo::Monitor when query succeeds
24 25 26 27 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 24 def succeeded(event) # Finish the event as succeeded finish("SUCCEEDED", event) end |