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

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/monitoring/event/command_failed.rb

Overview

Event that is fired when a command operation fails.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_name, database_name, address, request_id, operation_id, message, duration) ⇒ CommandFailed

Create the new event.

Examples:

Create the event.

Parameters:

  • command_name (String)

    The name of the command.

  • database_name (String)

    The database_name name.

  • address (Server::Address)

    The server address.

  • request_id (Integer)

    The request id.

  • operation_id (Integer)

    The operation id.

  • message (String)

    The error message.

  • duration (Float)

    The duration the command took in seconds.

Since:

  • 2.1.0



58
59
60
61
62
63
64
65
66
# File 'lib/mongo/monitoring/event/command_failed.rb', line 58

def initialize(command_name, database_name, address, request_id, operation_id, message, duration)
  @command_name = command_name
  @database_name = database_name
  @address = address
  @request_id = request_id
  @operation_id = operation_id
  @message = message
  @duration = duration
end

Instance Attribute Details

#addressServer::Address (readonly)

Returns address The server address.

Returns:

  • (Server::Address)

    address The server address.

Since:

  • 2.1.0



25
26
27
# File 'lib/mongo/monitoring/event/command_failed.rb', line 25

def address
  @address
end

#command_nameString (readonly)

Returns command_name The name of the command.

Returns:

  • (String)

    command_name The name of the command.

Since:

  • 2.1.0



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

def command_name
  @command_name
end

#database_nameString (readonly)

Returns database_name The name of the database_name.

Returns:

  • (String)

    database_name The name of the database_name.

Since:

  • 2.1.0



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

def database_name
  @database_name
end

#durationFloat (readonly)

Returns duration The duration of the command in seconds.

Returns:

  • (Float)

    duration The duration of the command in seconds.

Since:

  • 2.1.0



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

def duration
  @duration
end

#messageString (readonly)

Returns message The error message.

Returns:

  • (String)

    message The error message.

Since:

  • 2.1.0



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

def message
  @message
end

#operation_idInteger (readonly)

Returns operation_id The operation id.

Returns:

  • (Integer)

    operation_id The operation id.

Since:

  • 2.1.0



40
41
42
# File 'lib/mongo/monitoring/event/command_failed.rb', line 40

def operation_id
  @operation_id
end

#request_idInteger (readonly)

Returns request_id The request id.

Returns:

  • (Integer)

    request_id The request id.

Since:

  • 2.1.0



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

def request_id
  @request_id
end

Class Method Details

.generate(address, operation_id, payload, message, duration) ⇒ CommandFailed

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.

  • duration (Float)

    The duration of the command in seconds.

Returns:

Since:

  • 2.1.0



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/mongo/monitoring/event/command_failed.rb', line 82

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