Skip to content

Commit 251bd4b

Browse files
Merge v1.x into v2.x (#1446)
2 parents 5dda098 + 72d205f commit 251bd4b

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testRetryOnDifferentMongos(): void
6464

6565
// Step 4: Enable failed command event monitoring for client
6666
$subscriber = new class implements CommandSubscriber {
67-
/** @var int[] */
67+
/** @var string[] */
6868
public array $commandFailedServers = [];
6969

7070
public function commandStarted(CommandStartedEvent $event): void
@@ -77,7 +77,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void
7777

7878
public function commandFailed(CommandFailedEvent $event): void
7979
{
80-
$this->commandFailedServers[] = $event->getServerConnectionId();
80+
$this->commandFailedServers[] = $event->getHost() . ':' . $event->getPort();
8181
}
8282
};
8383

@@ -130,21 +130,21 @@ public function testRetryOnSameMongos(): void
130130

131131
// Step 4: Enable succeeded and failed command event monitoring
132132
$subscriber = new class implements CommandSubscriber {
133-
public ?int $commandSucceededServer = null;
134-
public ?int $commandFailedServer = null;
133+
public ?string $commandSucceededServer = null;
134+
public ?string $commandFailedServer = null;
135135

136136
public function commandStarted(CommandStartedEvent $event): void
137137
{
138138
}
139139

140140
public function commandSucceeded(CommandSucceededEvent $event): void
141141
{
142-
$this->commandSucceededServer = $event->getServerConnectionId();
142+
$this->commandSucceededServer = $event->getHost() . ':' . $event->getPort();
143143
}
144144

145145
public function commandFailed(CommandFailedEvent $event): void
146146
{
147-
$this->commandFailedServer = $event->getServerConnectionId();
147+
$this->commandFailedServer = $event->getHost() . ':' . $event->getPort();
148148
}
149149
};
150150

tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testRetryOnDifferentMongos(): void
6767

6868
// Step 4: Enable failed command event monitoring for client
6969
$subscriber = new class implements CommandSubscriber {
70-
/** @var int[] */
70+
/** @var string[] */
7171
public array $commandFailedServers = [];
7272

7373
public function commandStarted(CommandStartedEvent $event): void
@@ -80,7 +80,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void
8080

8181
public function commandFailed(CommandFailedEvent $event): void
8282
{
83-
$this->commandFailedServers[] = $event->getServerConnectionId();
83+
$this->commandFailedServers[] = $event->getHost() . ':' . $event->getPort();
8484
}
8585
};
8686

tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ public function testRetryOnSameMongos(): void
4949

5050
// Step 4: Enable succeeded and failed command event monitoring
5151
$subscriber = new class implements CommandSubscriber {
52-
public ?int $commandSucceededServer = null;
53-
public ?int $commandFailedServer = null;
52+
public ?string $commandSucceededServer = null;
53+
public ?string $commandFailedServer = null;
5454

5555
public function commandStarted(CommandStartedEvent $event): void
5656
{
5757
}
5858

5959
public function commandSucceeded(CommandSucceededEvent $event): void
6060
{
61-
$this->commandSucceededServer = $event->getServerConnectionId();
61+
$this->commandSucceededServer = $event->getHost() . ':' . $event->getPort();
6262
}
6363

6464
public function commandFailed(CommandFailedEvent $event): void
6565
{
66-
$this->commandFailedServer = $event->getServerConnectionId();
66+
$this->commandFailedServer = $event->getHost() . ':' . $event->getPort();
6767
}
6868
};
6969

tests/UnifiedSpecTests/EventCollector.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,17 @@ private function handleCommandMonitoringEvent(CommandStartedEvent|CommandSucceed
107107
'name' => self::getEventName($event),
108108
'observedAt' => microtime(true),
109109
'commandName' => $event->getCommandName(),
110-
'connectionId' => $event->getServerConnectionId(),
111-
'requestId' => $event->getRequestId(),
110+
'databaseName' => $event->getDatabaseName(),
112111
'operationId' => $event->getOperationId(),
112+
'requestId' => $event->getRequestId(),
113+
'server' => $event->getHost() . ':' . $event->getPort(),
114+
'serverConnectionId' => $event->getServerConnectionId(),
115+
'serviceId' => $event->getServiceId(),
113116
];
114117

115118
/* Note: CommandStartedEvent.command and CommandSucceededEvent.reply can
116119
* be omitted from logged events. */
117120

118-
if ($event instanceof CommandStartedEvent) {
119-
$log['databaseName'] = $event->getDatabaseName();
120-
}
121-
122121
if ($event instanceof CommandSucceededEvent) {
123122
$log['duration'] = $event->getDurationMicros();
124123
}

0 commit comments

Comments
 (0)