Class: Mongo::Monitoring
- Inherits:
-
Object
- Object
- Mongo::Monitoring
- Includes:
- Subscribable
- Defined in:
- lib/mongo/monitoring.rb,
lib/mongo/monitoring/publishable.rb,
lib/mongo/monitoring/event/secure.rb,
lib/mongo/monitoring/event/server_closed.rb,
lib/mongo/monitoring/sdam_log_subscriber.rb,
lib/mongo/monitoring/event/command_failed.rb,
lib/mongo/monitoring/event/server_opening.rb,
lib/mongo/monitoring/event/command_started.rb,
lib/mongo/monitoring/event/topology_closed.rb,
lib/mongo/monitoring/command_log_subscriber.rb,
lib/mongo/monitoring/event/topology_changed.rb,
lib/mongo/monitoring/event/topology_opening.rb,
lib/mongo/monitoring/event/command_succeeded.rb,
lib/mongo/monitoring/server_closed_log_subscriber.rb,
lib/mongo/monitoring/server_opening_log_subscriber.rb,
lib/mongo/monitoring/topology_changed_log_subscriber.rb,
lib/mongo/monitoring/topology_opening_log_subscriber.rb,
lib/mongo/monitoring/event/server_description_changed.rb,
lib/mongo/monitoring/server_description_changed_log_subscriber.rb
Overview
The class defines behaviour for the performance monitoring API.
Defined Under Namespace
Modules: Event, Global, Publishable, Subscribable Classes: CommandLogSubscriber, SDAMLogSubscriber, ServerClosedLogSubscriber, ServerDescriptionChangedLogSubscriber, ServerOpeningLogSubscriber, TopologyChangedLogSubscriber, TopologyOpeningLogSubscriber
Constant Summary collapse
- COMMAND =
The command topic.
'Command'.freeze
- SERVER_CLOSED =
Server closed topic.
'ServerClosed'.freeze
- SERVER_DESCRIPTION_CHANGED =
Server description changed topic.
'ServerDescriptionChanged'.freeze
- SERVER_OPENING =
Server opening topic.
'ServerOpening'.freeze
- TOPOLOGY_CHANGED =
Topology changed topic.
'TopologyChanged'.freeze
- TOPOLOGY_CLOSED =
Topology closed topic.
'TopologyClosed'.freeze
- TOPOLOGY_OPENING =
Topology opening topic.
'TopologyOpening'.freeze
- @@operation_id =
0- @@operation_id_lock =
Mutex.new
Class Method Summary collapse
-
.next_operation_id ⇒ Integer
Used for generating unique operation ids to link events together.
Instance Method Summary collapse
-
#failed(topic, event) ⇒ Object
Publish a failed event.
-
#initialize(options = {}) ⇒ Monitoring
constructor
private
Initialize the monitoring.
-
#started(topic, event) ⇒ Object
Publish a started event.
-
#succeeded(topic, event) ⇒ Object
Publish a succeeded event.
Methods included from Subscribable
#subscribe, #subscribers, #subscribers?, #unsubscribe
Constructor Details
#initialize(options = {}) ⇒ Monitoring
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.
Initialize the monitoring.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/mongo/monitoring.rb', line 202 def initialize( = {}) if [:monitoring] != false Global.subscribers.each do |topic, subscribers| subscribers.each do |subscriber| subscribe(topic, subscriber) end end subscribe(COMMAND, CommandLogSubscriber.new()) subscribe(SERVER_OPENING, ServerOpeningLogSubscriber.new()) subscribe(SERVER_CLOSED, ServerClosedLogSubscriber.new()) subscribe(SERVER_DESCRIPTION_CHANGED, ServerDescriptionChangedLogSubscriber.new()) subscribe(TOPOLOGY_OPENING, TopologyOpeningLogSubscriber.new()) subscribe(TOPOLOGY_CHANGED, TopologyChangedLogSubscriber.new()) end end |
Class Method Details
.next_operation_id ⇒ Integer
Used for generating unique operation ids to link events together.
68 69 70 71 72 |
# File 'lib/mongo/monitoring.rb', line 68 def self.next_operation_id @@operation_id_lock.synchronize do @@operation_id += 1 end end |
Instance Method Details
#failed(topic, event) ⇒ Object
Publish a failed event.
253 254 255 |
# File 'lib/mongo/monitoring.rb', line 253 def failed(topic, event) subscribers_for(topic).each{ |subscriber| subscriber.failed(event) } end |
#started(topic, event) ⇒ Object
Publish a started event.
227 228 229 |
# File 'lib/mongo/monitoring.rb', line 227 def started(topic, event) subscribers_for(topic).each{ |subscriber| subscriber.started(event) } end |
#succeeded(topic, event) ⇒ Object
Publish a succeeded event.
240 241 242 |
# File 'lib/mongo/monitoring.rb', line 240 def succeeded(topic, event) subscribers_for(topic).each{ |subscriber| subscriber.succeeded(event) } end |