Class: BrainzLab::Instrumentation::MongoDBInstrumentation::CommandSubscriber
- Inherits:
-
Object
- Object
- BrainzLab::Instrumentation::MongoDBInstrumentation::CommandSubscriber
- Defined in:
- lib/brainzlab/instrumentation/mongodb.rb
Overview
MongoDB Command Subscriber
Constant Summary collapse
- SKIP_COMMANDS =
%w[isMaster ismaster buildInfo getLastError saslStart saslContinue].freeze
Instance Method Summary collapse
-
#failed(event) ⇒ Object
Called when command fails.
-
#initialize ⇒ CommandSubscriber
constructor
A new instance of CommandSubscriber.
-
#started(event) ⇒ Object
Called when command starts.
-
#succeeded(event) ⇒ Object
Called when command succeeds.
Constructor Details
#initialize ⇒ CommandSubscriber
Returns a new instance of CommandSubscriber.
64 65 66 |
# File 'lib/brainzlab/instrumentation/mongodb.rb', line 64 def initialize @commands = {} end |
Instance Method Details
#failed(event) ⇒ Object
Called when command fails
86 87 88 |
# File 'lib/brainzlab/instrumentation/mongodb.rb', line 86 def failed(event) record_command(event, success: false, error: event.) end |
#started(event) ⇒ Object
Called when command starts
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/brainzlab/instrumentation/mongodb.rb', line 69 def started(event) return if skip_command?(event.command_name) @commands[event.request_id] = { started_at: Time.now.utc, command_name: event.command_name, database: event.database_name, collection: extract_collection(event) } end |
#succeeded(event) ⇒ Object
Called when command succeeds
81 82 83 |
# File 'lib/brainzlab/instrumentation/mongodb.rb', line 81 def succeeded(event) record_command(event, success: true) end |