Class: Mongo::Monitoring::Event::CommandStarted
- Inherits:
-
Event::Base
- Object
- Event::Base
- Mongo::Monitoring::Event::CommandStarted
- Includes:
- Secure
- Defined in:
- lib/mongo/monitoring/event/command_started.rb
Overview
Event that is fired when a command operation starts.
Constant Summary
Constants included from Secure
Instance Attribute Summary collapse
-
#address ⇒ Server::Address
readonly
Address The server address.
-
#command ⇒ BSON::Document
readonly
Command The command arguments.
-
#command_name ⇒ String
readonly
Command_name The name of the command.
- #connection_generation ⇒ Object readonly private
-
#connection_id ⇒ Integer
readonly
private
The ID for the connection over which the command is sent.
-
#database_name ⇒ String
readonly
Database_name The name of the database_name.
-
#operation_id ⇒ Integer
readonly
Operation_id The operation id.
-
#request_id ⇒ Integer
readonly
Request_id The request id.
-
#sensitive ⇒ true | false
readonly
private
Whether the event contains sensitive data.
-
#server_connection_id ⇒ Integer
readonly
Server_connection_id The server connection id.
-
#service_id ⇒ nil | Object
readonly
The service id, if any.
-
#socket_object_id ⇒ Object
readonly
private
object_id of the socket object used for this command.
Class Method Summary collapse
-
.generate(address, operation_id, payload, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil) ⇒ CommandStarted
private
Create the event from a wire protocol message payload.
Instance Method Summary collapse
-
#initialize(command_name, database_name, address, request_id, operation_id, command, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil) ⇒ CommandStarted
constructor
private
Create the new event.
-
#inspect ⇒ String
Returns a concise yet useful summary of the event.
-
#summary ⇒ String
Returns a concise yet useful summary of the event.
Methods included from Secure
#compression_allowed?, #redacted, #sensitive?
Constructor Details
#initialize(command_name, database_name, address, request_id, operation_id, command, 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 new event.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 85 def initialize(command_name, database_name, address, request_id, operation_id, command, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil ) @command_name = command_name.to_s @database_name = database_name @address = address @request_id = request_id @operation_id = operation_id @service_id = service_id @sensitive = sensitive?( command_name: @command_name, document: command ) @command = redacted(command_name, command) @socket_object_id = socket_object_id @connection_id = connection_id @connection_generation = connection_generation @server_connection_id = server_connection_id end |
Instance Attribute Details
#address ⇒ Server::Address (readonly)
Returns address The server address.
29 30 31 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 29 def address @address end |
#command ⇒ BSON::Document (readonly)
Returns command The command arguments.
32 33 34 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 32 def command @command end |
#command_name ⇒ String (readonly)
Returns command_name The name of the command.
35 36 37 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 35 def command_name @command_name end |
#connection_generation ⇒ Object (readonly)
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.
55 56 57 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 55 def connection_generation @connection_generation end |
#connection_id ⇒ Integer (readonly)
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.
Returns The ID for the connection over which the command is sent.
61 62 63 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 61 def connection_id @connection_id end |
#database_name ⇒ String (readonly)
Returns database_name The name of the database_name.
38 39 40 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 38 def database_name @database_name end |
#operation_id ⇒ Integer (readonly)
Returns operation_id The operation id.
41 42 43 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 41 def operation_id @operation_id end |
#request_id ⇒ Integer (readonly)
Returns request_id The request id.
44 45 46 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 44 def request_id @request_id end |
#sensitive ⇒ true | false (readonly)
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.
Returns Whether the event contains sensitive data.
69 70 71 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 69 def sensitive @sensitive end |
#server_connection_id ⇒ Integer (readonly)
Returns server_connection_id The server connection id.
64 65 66 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 64 def server_connection_id @server_connection_id end |
#service_id ⇒ nil | Object (readonly)
Returns The service id, if any.
47 48 49 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 47 def service_id @service_id end |
#socket_object_id ⇒ Object (readonly)
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.
object_id of the socket object used for this command.
52 53 54 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 52 def socket_object_id @socket_object_id end |
Class Method Details
.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 |
Instance Method Details
#inspect ⇒ String
Returns a concise yet useful summary of the event.
179 180 181 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 179 def inspect "#<{#{self.class} #{database_name}.#{command_name} command=#{command}>" end |
#summary ⇒ String
This method is experimental and subject to change.
Returns a concise yet useful summary of the event.
114 115 116 |
# File 'lib/mongo/monitoring/event/command_started.rb', line 114 def summary "#<#{short_class_name} address=#{address} #{database_name}.#{command_name} command=#{command_summary}>" end |