Class: Mongo::Monitoring::Event::CommandStarted
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Mongo::Event::Base
|
|
Instance Chain:
self,
Secure ,
::Mongo::Event::Base
|
|
Inherits: |
Mongo::Event::Base
|
Defined in: | lib/mongo/monitoring/event/command_started.rb |
Overview
::Mongo::Monitoring::Event
that is fired when a command operation starts.
Constant Summary
Secure
- Included
Class Method Summary
-
.generate(address, operation_id, payload, socket_object_id: nil, connection_id: nil, connection_generation: nil, server_connection_id: nil, service_id: nil) ⇒ CommandStarted
Internal use only
Internal use only
Create the event from a wire protocol message payload.
-
.new(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
Internal use only
Internal use only
Create the new event.
Instance Attribute Summary
- #address ⇒ Server::Address readonly
- #command ⇒ BSON::Document readonly
- #command_name ⇒ String readonly
- #connection_generation readonly Internal use only Internal use only
- #connection_id ⇒ Integer readonly Internal use only Internal use only
- #database_name ⇒ String readonly
- #operation_id ⇒ Integer readonly
- #request_id ⇒ Integer readonly
- #sensitive ⇒ true | false readonly Internal use only Internal use only
- #server_connection_id ⇒ Integer readonly
- #service_id ⇒ nil | Object readonly
-
#socket_object_id
readonly
Internal use only
Internal use only
object_id of the socket object used for this command.
Instance Method Summary
-
#inspect ⇒ String
Returns a concise yet useful summary of the event.
-
#summary ⇒ String
Returns a concise yet useful summary of the event.
-
#command_summary ⇒ String
private
Returns the command, formatted as a string, with automatically added keys elided ($clusterTime, lsid, signature).
Secure
- Included
#compression_allowed? | Is compression allowed for a given command message. |
#redacted | Redact secure information from the document if: |
#sensitive? | Check whether the command is sensitive in terms of command monitoring spec. |
::Mongo::Event::Base
- Inherited
#summary | Returns a concise yet useful summary of the event. |
#short_class_name |
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
Create the event from a wire protocol message payload.
# 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 Attribute Details
#address ⇒ Server::Address
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 29
attr_reader :address
#command ⇒ BSON::Document
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 32
attr_reader :command
#command_name ⇒ String
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 35
attr_reader :command_name
#connection_generation (readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 55
attr_reader :connection_generation
#connection_id ⇒ Integer
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 61
attr_reader :connection_id
#database_name ⇒ String
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 38
attr_reader :database_name
#operation_id ⇒ Integer
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 41
attr_reader :operation_id
#request_id ⇒ Integer
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 44
attr_reader :request_id
#sensitive ⇒ true
| false
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 69
attr_reader :sensitive
#server_connection_id ⇒ Integer
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 64
attr_reader :server_connection_id
#service_id ⇒ nil
| Object
(readonly)
# File 'lib/mongo/monitoring/event/command_started.rb', line 47
attr_reader :service_id
#socket_object_id (readonly)
object_id of the socket object used for this command.
# File 'lib/mongo/monitoring/event/command_started.rb', line 52
attr_reader :socket_object_id
Instance Method Details
#command_summary ⇒ String
(private)
Returns the command, formatted as a string, with automatically added keys elided ($clusterTime, lsid, signature).
# File 'lib/mongo/monitoring/event/command_started.rb', line 122
private def command_summary command = self.command remove_keys = %w($clusterTime lsid signature) if remove_keys.any? { |k| command.key?(k) } command = Hash[command.reject { |k, v| remove_keys.include?(k) }] suffix = ' ...' else suffix = '' end command.map do |k, v| "#{k}=#{v.inspect}" end.join(' ') + suffix end
#inspect ⇒ String
Returns a concise yet useful summary of the event.
# 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.
# 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