diff --git a/tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php b/tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php index 958e74b07..2040c3d49 100644 --- a/tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php +++ b/tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php @@ -64,7 +64,7 @@ public function testRetryOnDifferentMongos(): void // Step 4: Enable failed command event monitoring for client $subscriber = new class implements CommandSubscriber { - /** @var int[] */ + /** @var string[] */ public array $commandFailedServers = []; public function commandStarted(CommandStartedEvent $event): void @@ -77,7 +77,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void public function commandFailed(CommandFailedEvent $event): void { - $this->commandFailedServers[] = $event->getServerConnectionId(); + $this->commandFailedServers[] = $event->getHost() . ':' . $event->getPort(); } }; @@ -130,8 +130,8 @@ public function testRetryOnSameMongos(): void // Step 4: Enable succeeded and failed command event monitoring $subscriber = new class implements CommandSubscriber { - public ?int $commandSucceededServer = null; - public ?int $commandFailedServer = null; + public ?string $commandSucceededServer = null; + public ?string $commandFailedServer = null; public function commandStarted(CommandStartedEvent $event): void { @@ -139,12 +139,12 @@ public function commandStarted(CommandStartedEvent $event): void public function commandSucceeded(CommandSucceededEvent $event): void { - $this->commandSucceededServer = $event->getServerConnectionId(); + $this->commandSucceededServer = $event->getHost() . ':' . $event->getPort(); } public function commandFailed(CommandFailedEvent $event): void { - $this->commandFailedServer = $event->getServerConnectionId(); + $this->commandFailedServer = $event->getHost() . ':' . $event->getPort(); } }; diff --git a/tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php b/tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php index 6d2fd7d50..f78ba3b75 100644 --- a/tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php +++ b/tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php @@ -67,7 +67,7 @@ public function testRetryOnDifferentMongos(): void // Step 4: Enable failed command event monitoring for client $subscriber = new class implements CommandSubscriber { - /** @var int[] */ + /** @var string[] */ public array $commandFailedServers = []; public function commandStarted(CommandStartedEvent $event): void @@ -80,7 +80,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void public function commandFailed(CommandFailedEvent $event): void { - $this->commandFailedServers[] = $event->getServerConnectionId(); + $this->commandFailedServers[] = $event->getHost() . ':' . $event->getPort(); } }; diff --git a/tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php b/tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php index 7357b30f2..565ebf201 100644 --- a/tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php +++ b/tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php @@ -49,8 +49,8 @@ public function testRetryOnSameMongos(): void // Step 4: Enable succeeded and failed command event monitoring $subscriber = new class implements CommandSubscriber { - public ?int $commandSucceededServer = null; - public ?int $commandFailedServer = null; + public ?string $commandSucceededServer = null; + public ?string $commandFailedServer = null; public function commandStarted(CommandStartedEvent $event): void { @@ -58,12 +58,12 @@ public function commandStarted(CommandStartedEvent $event): void public function commandSucceeded(CommandSucceededEvent $event): void { - $this->commandSucceededServer = $event->getServerConnectionId(); + $this->commandSucceededServer = $event->getHost() . ':' . $event->getPort(); } public function commandFailed(CommandFailedEvent $event): void { - $this->commandFailedServer = $event->getServerConnectionId(); + $this->commandFailedServer = $event->getHost() . ':' . $event->getPort(); } }; diff --git a/tests/UnifiedSpecTests/EventCollector.php b/tests/UnifiedSpecTests/EventCollector.php index 7e31328dd..8acf41de7 100644 --- a/tests/UnifiedSpecTests/EventCollector.php +++ b/tests/UnifiedSpecTests/EventCollector.php @@ -119,18 +119,17 @@ private function handleCommandMonitoringEvent($event): void 'name' => self::getEventName($event), 'observedAt' => microtime(true), 'commandName' => $event->getCommandName(), - 'connectionId' => $event->getServerConnectionId(), - 'requestId' => $event->getRequestId(), + 'databaseName' => $event->getDatabaseName(), 'operationId' => $event->getOperationId(), + 'requestId' => $event->getRequestId(), + 'server' => $event->getHost() . ':' . $event->getPort(), + 'serverConnectionId' => $event->getServerConnectionId(), + 'serviceId' => $event->getServiceId(), ]; /* Note: CommandStartedEvent.command and CommandSucceededEvent.reply can * be omitted from logged events. */ - if ($event instanceof CommandStartedEvent) { - $log['databaseName'] = $event->getDatabaseName(); - } - if ($event instanceof CommandSucceededEvent) { $log['duration'] = $event->getDurationMicros(); }