123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Monitoring::Event::CommandFailed

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Mongo::Event::Base
Defined in: lib/mongo/monitoring/event/command_failed.rb

Overview

::Mongo::Monitoring::Event that is fired when a command operation fails.

Since:

  • 2.1.0

Constant Summary

Secure - Included

REDACTED_COMMANDS

Class Method Summary

Instance Attribute Summary

Instance Method Summary

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, message, failure, duration, started_event:, server_connection_id: nil, service_id: nil) ⇒ CommandFailed

This method is for internal use only.

Create the event from a wire protocol message payload.

Examples:

Create the event.

CommandFailed.generate(address, 1, payload, duration)

Parameters:

  • address (Server::Address)

    The server address.

  • operation_id (Integer)

    The operation id.

  • payload (Hash)

    The message payload.

  • message (String)

    The error message.

  • failure (BSON::Document)

    The error document, if any.

  • duration (Float)

    The duration of the command in seconds.

  • started_event (Monitoring::Event::CommandStarted)

    The corresponding started event.

  • service_id (Object)

    The service id, if any.

Returns:

  • (CommandFailed)

    The event.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 132

def self.generate(address, operation_id, payload, message,
  failure, duration, started_event:, server_connection_id: nil,
  service_id: nil
)
  new(
    payload[:command_name],
    payload[:database_name],
    address,
    payload[:request_id],
    operation_id,
    message,
    failure,
    duration,
    started_event: started_event,
    server_connection_id: server_connection_id,
    service_id: service_id,
  )
end

Instance Attribute Details

#addressServer::Address (readonly)

Returns:

  • (Server::Address)

    address The server address.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 29

attr_reader :address

#command_nameString (readonly)

Returns:

  • (String)

    command_name The name of the command.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 32

attr_reader :command_name

#database_nameString (readonly)

Returns:

  • (String)

    database_name The name of the database_name.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 35

attr_reader :database_name

#durationFloat (readonly)

Returns:

  • (Float)

    duration The duration of the command in seconds.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 38

attr_reader :duration

#failureBSON::Document (readonly)

Returns:

  • (BSON::Document)

    failure The error document, if present. This will only be filled out for errors communicated by a MongoDB server. In other situations, for example in case of a network error, this attribute may be nil.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 44

attr_reader :failure

#messageString (readonly)

Returns:

  • (String)

    message The error message. Unlike the error document, the error message should always be present.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 48

attr_reader :message

#operation_idInteger (readonly)

Returns:

  • (Integer)

    operation_id The operation id.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 51

attr_reader :operation_id

#request_idInteger (readonly)

Returns:

  • (Integer)

    request_id The request id.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 54

attr_reader :request_id

#server_connection_idInteger (readonly)

Returns:

  • (Integer)

    server_connection_id The server connection id.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 57

attr_reader :server_connection_id

#service_idnil | Object (readonly)

Returns:

  • (nil | Object)

    The service id, if any.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 60

attr_reader :service_id

#started_eventMonitoring::Event::CommandStarted (readonly)

This method is for internal use only.

Returns:

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 66

attr_reader :started_event

Instance Method Details

#summaryString

Note:

This method is experimental and subject to change.

Returns a concise yet useful summary of the event.

Returns:

  • (String)

    String summary of the event.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/monitoring/event/command_failed.rb', line 109

def summary
  "#<#{short_class_name} address=#{address} #{database_name}.#{command_name}>"
end