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
32 33 34 35 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 32 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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 38 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 ) # Send global query metrics Appsignal.add_distribution_value( "mongodb_query_duration", event.duration, :database => event.database_name ) 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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 8 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
26 27 28 29 |
# File 'lib/appsignal/integrations/mongo_ruby_driver.rb', line 26 def succeeded(event) # Finish the event as succeeded finish("SUCCEEDED", event) end |