From 859573c67f86fd979d3411aea4d707bcf8eba9df Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 11 Feb 2021 08:57:52 -0500 Subject: [PATCH 1/2] Revert "RUBY-2484 do not observe command events (#2172)" This reverts commit 74865188bd5149548c640c8835e6bb19781ab542. --- spec/runners/unified/test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/runners/unified/test.rb b/spec/runners/unified/test.rb index 95db878bc6..55defe3449 100644 --- a/spec/runners/unified/test.rb +++ b/spec/runners/unified/test.rb @@ -105,6 +105,7 @@ def create_entities end end opts[:sdam_proc] = lambda do |client| + client.subscribe(Mongo::Monitoring::COMMAND, subscriber) client.subscribe(Mongo::Monitoring::CONNECTION_POOL, subscriber) end end From 7becaf6217dfb91719258db39bdd5e17bdb9dfa0 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 11 Feb 2021 09:15:12 -0500 Subject: [PATCH 2/2] RUBY-2484 Updated command event handling for DAT --- spec/runners/unified/event_subscriber.rb | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/spec/runners/unified/event_subscriber.rb b/spec/runners/unified/event_subscriber.rb index c0f686f9bb..9643ad871c 100644 --- a/spec/runners/unified/event_subscriber.rb +++ b/spec/runners/unified/event_subscriber.rb @@ -31,43 +31,44 @@ def add_wanted_events(kind) class StoringEventSubscriber def initialize(&block) - @operations = {} @handler = block end def started(event) - started_at = Time.now - @operations[event.operation_id] = [event, started_at] @handler.call( 'name' => event.class.name.sub(/.*::/, '') + 'Event', 'commandName' => event.command_name, - 'startTime' => started_at.to_f, + 'databaseName' => event.database_name, + 'observedAt' => Time.now.to_f, 'address' => event.address.seed, + 'requestId' => event.request_id, + 'operationId' => event.operation_id, + 'connectionId' => event.connection_id, ) end def succeeded(event) - started_event, started_at = @operations.delete(event.operation_id) - raise "Started event for #{event.operation_id} not found" unless started_event @handler.call( 'name' => event.class.name.sub(/.*::/, '') + 'Event', - 'commandName' => started_event.command_name, + 'commandName' => event.command_name, 'duration' => event.duration, - 'startTime' => started_at.to_f, - 'address' => started_event.address.seed, + 'observedAt' => Time.now.to_f, + 'address' => event.address.seed, + 'requestId' => event.request_id, + 'operationId' => event.operation_id, ) end def failed(event) - started_event, started_at = @operations.delete(event.operation_id) - raise "Started event for #{event.operation_id} not found" unless started_event @handler.call( 'name' => event.class.name.sub(/.*::/, '') + 'Event', - 'commandName' => started_event.command_name, + 'commandName' => event.command_name, 'duration' => event.duration, 'failure' => event.failure, - 'startTime' => started_at.to_f, - 'address' => started_event.address.seed, + 'observedAt' => Time.now.to_f, + 'address' => event.address.seed, + 'requestId' => event.request_id, + 'operationId' => event.operation_id, ) end