Skip to content

Commit a7bc2ce

Browse files
DRIVERS-2884 Add event monitoring to pending read
1 parent 9787a12 commit a7bc2ce

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

x/mongo/driver/topology/pool.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,19 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
832832
logPoolMessage(pool, logger.ConnectionPendingReadFailed, keysAndValues...)
833833
}
834834

835+
if pool.monitor != nil && someErr != nil {
836+
event := &event.PoolEvent{
837+
Type: event.ConnectionPendingReadFailed,
838+
Address: pool.address.String(),
839+
ConnectionID: conn.driverConnectionID,
840+
RequestID: conn.requestID,
841+
RemainingTime: *conn.remainingTime,
842+
Reason: someErr.Error(),
843+
}
844+
845+
pool.monitor.Event(event)
846+
}
847+
835848
// If we have exceeded the time limit, then close the connection.
836849
if conn.remainingTime != nil && *conn.remainingTime < 0 {
837850
if err := conn.close(); err != nil {
@@ -928,6 +941,17 @@ func awaitPendingRead(ctx context.Context, pool *pool, conn *connection) error {
928941
logPoolMessage(pool, logger.ConnectionPendingReadSucceeded, keysAndValues...)
929942
}
930943

944+
if pool.monitor != nil {
945+
event := &event.PoolEvent{
946+
Type: event.ConnectionPendingReadSucceeded,
947+
Address: pool.address.String(),
948+
ConnectionID: conn.driverConnectionID,
949+
Duration: time.Since(st),
950+
}
951+
952+
pool.monitor.Event(event)
953+
}
954+
931955
conn.awaitRemainingBytes = nil
932956
conn.remainingTime = nil
933957

0 commit comments

Comments
 (0)