Class: Mongo::Monitoring::Event::CommandSucceeded

Inherits:
Event::Base
  • Object
show all
Includes:
Secure
Defined in:
lib/mongo/monitoring/event/command_succeeded.rb

Overview

Event that is fired when a command operation succeeds.

Since:

  • 2.1.0

Constant Summary

Constants included from Secure

Secure::REDACTED_COMMANDS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Secure

#compression_allowed?, #redacted

Constructor Details

#initialize(command_name, database_name, address, request_id, operation_id, reply, duration) ⇒ CommandSucceeded

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.

Examples:

Create the event.

Since:

  • 2.1.0

Parameters:

  • The name of the command.

  • The database name.

  • The server address.

  • The request id.

  • The operation id.

  • The command reply.

  • The duration the command took in seconds.

API:

  • private



60
61
62
63
64
65
66
67
68
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 60

def initialize(command_name, database_name, address, request_id, operation_id, reply, duration)
  @command_name = command_name.to_s
  @database_name = database_name
  @address = address
  @request_id = request_id
  @operation_id = operation_id
  @reply = redacted(command_name, reply)
  @duration = duration
end

Instance Attribute Details

#addressServer::Address (readonly)

Returns address The server address.

Since:

  • 2.1.0

Returns:

  • address The server address.



26
27
28
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 26

def address
  @address
end

#command_nameString (readonly)

Returns command_name The name of the command.

Since:

  • 2.1.0

Returns:

  • command_name The name of the command.



29
30
31
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 29

def command_name
  @command_name
end

#database_nameString (readonly)

Returns database_name The name of the database.

Since:

  • 2.1.0

Returns:

  • database_name The name of the database.



35
36
37
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 35

def database_name
  @database_name
end

#durationFloat (readonly)

Returns duration The duration of the event.

Since:

  • 2.1.0

Returns:

  • duration The duration of the event.



38
39
40
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 38

def duration
  @duration
end

#operation_idInteger (readonly)

Returns operation_id The operation id.

Since:

  • 2.1.0

Returns:

  • operation_id The operation id.



41
42
43
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 41

def operation_id
  @operation_id
end

#replyBSON::Document (readonly)

Returns reply The command reply.

Since:

  • 2.1.0

Returns:

  • reply The command reply.



32
33
34
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 32

def reply
  @reply
end

#request_idInteger (readonly)

Returns request_id The request id.

Since:

  • 2.1.0

Returns:

  • request_id The request id.



44
45
46
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 44

def request_id
  @request_id
end

Class Method Details

.generate(address, operation_id, command_payload, reply_payload, duration) ⇒ CommandCompleted

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.

Examples:

Create the event.

CommandSucceeded.generate(address, 1, command_payload, reply_payload, 0.5)

Since:

  • 2.1.0

Parameters:

  • The server address.

  • The operation id.

  • The command message payload.

  • The reply message payload.

  • The duration of the command in seconds.

Returns:

  • The event.

API:

  • private



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 96

def self.generate(address, operation_id, command_payload, reply_payload, duration)
  new(
    command_payload[:command_name],
    command_payload[:database_name],
    address,
    command_payload[:request_id],
    operation_id,
    generate_reply(command_payload, reply_payload),
    duration
  )
end

Instance Method Details

#summaryString

Note:

This method is experimental and subject to change.

Returns a concise yet useful summary of the event.

Since:

  • 2.1.0

Returns:

  • String summary of the event.

API:

  • experimental



77
78
79
# File 'lib/mongo/monitoring/event/command_succeeded.rb', line 77

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