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

Inherits:
Event::Base
  • Object
show all
Includes:
Secure
Defined in:
build/ruby-driver-master/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, #sensitive?

Constructor Details

#initialize(command_name, database_name, address, request_id, operation_id, reply, duration, started_event:, service_id: nil) ⇒ 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.

Parameters:

  • command_name (String)

    The name of the command.

  • database_name (String)

    The database name.

  • address (Server::Address)

    The server address.

  • request_id (Integer)

    The request id.

  • operation_id (Integer)

    The operation id.

  • reply (BSON::Document)

    The command reply.

  • duration (Float)

    The duration the command took in seconds.

  • started_event (Monitoring::Event::CommandStarted)

    The corresponding started event.

  • service_id (Object) (defaults to: nil)

    The service id, if any.

Since:

  • 2.1.0



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 75

def initialize(command_name, database_name, address, request_id,
  operation_id, reply, duration, started_event:, 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
  @started_event = started_event
  @reply = redacted(command_name, reply)
  @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



29
30
31
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 29

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



32
33
34
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 32

def command_name
  @command_name
end

#database_nameString (readonly)

Returns database_name The name of the database.

Returns:

  • (String)

    database_name The name of the database.

Since:

  • 2.1.0



38
39
40
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 38

def database_name
  @database_name
end

#durationFloat (readonly)

Returns duration The duration of the event.

Returns:

  • (Float)

    duration The duration of the event.

Since:

  • 2.1.0



41
42
43
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 41

def duration
  @duration
end

#operation_idInteger (readonly)

Returns operation_id The operation id.

Returns:

  • (Integer)

    operation_id The operation id.

Since:

  • 2.1.0



44
45
46
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 44

def operation_id
  @operation_id
end

#replyBSON::Document (readonly)

Returns reply The command reply.

Returns:

  • (BSON::Document)

    reply The command reply.

Since:

  • 2.1.0



35
36
37
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 35

def reply
  @reply
end

#request_idInteger (readonly)

Returns request_id The request id.

Returns:

  • (Integer)

    request_id The request id.

Since:

  • 2.1.0



47
48
49
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 47

def request_id
  @request_id
end

#service_idnil | Object (readonly)

Returns The service id, if any.

Returns:

  • (nil | Object)

    The service id, if any.

Since:

  • 2.1.0



50
51
52
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 50

def service_id
  @service_id
end

#started_eventMonitoring::Event::CommandStarted (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 started_event The corresponding started event.

Returns:

Since:

  • 2.1.0



56
57
58
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 56

def started_event
  @started_event
end

Class Method Details

.generate(address, operation_id, command_payload, reply_payload, duration, started_event:, service_id: nil) ⇒ 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)

Parameters:

  • address (Server::Address)

    The server address.

  • operation_id (Integer)

    The operation id.

  • command_payload (Hash)

    The command message payload.

  • reply_payload (Hash)

    The reply message payload.

  • duration (Float)

    The duration of the command in seconds.

  • started_event (Monitoring::Event::CommandStarted)

    The corresponding started event.

  • service_id (Object) (defaults to: nil)

    The service id, if any.

Returns:

  • (CommandCompleted)

    The event.

Since:

  • 2.1.0



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 118

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

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



96
97
98
# File 'build/ruby-driver-master/lib/mongo/monitoring/event/command_succeeded.rb', line 96

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