From 56f70b32466fda4fc1d58f70a011efba596166fd Mon Sep 17 00:00:00 2001 From: andrew rumble Date: Tue, 13 Aug 2024 17:11:51 +0100 Subject: [PATCH] Support v5 of mongodb when recording metrics GitOrigin-RevId: 6365fa54b0b50dc8527fe75f371c53a43e2c5a72 --- libraries/metrics/mongodb.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/metrics/mongodb.js b/libraries/metrics/mongodb.js index 055675437a..c9f4e0b992 100644 --- a/libraries/metrics/mongodb.js +++ b/libraries/metrics/mongodb.js @@ -65,7 +65,8 @@ function monitor(mongoClient) { const servers = mongoClient.topology?.s?.servers if (servers != null) { for (const [address, server] of servers) { - const pool = server.s?.pool + // The server object is different between v4 and v5 (c.f. https://github.com/mongodb/node-mongodb-native/pull/3645) + const pool = server.s?.pool || server.pool if (pool == null) { continue }