Method: Mongo::Monitoring::Event::CommandStarted.generate
- Defined in:
- lib/mongo/monitoring/event/command_started.rb
.generate(address, operation_id, payload, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil) ⇒ CommandStarted
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.
Create the event from a wire protocol message payload.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 150 def self.generate(address, operation_id, payload, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil ) new( payload[:command_name], payload[:database_name], address, payload[:request_id], operation_id, # All op_msg payloads have a $db field. Legacy payloads do not # have a $db field. To emulate op_msg when publishing command # monitoring events for legacy servers, add $db to the payload, # copying the database name. Note that the database name is also # available as a top-level attribute on the command started event. payload[:command].merge('$db' => payload[:database_name]), socket_object_id: socket_object_id, connection_id: connection_id, connection_generation: connection_generation, server_connection_id: server_connection_id, service_id: service_id, ) end |