File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ def __init__(
149149 self ._listeners = self ._settings ._pool_options ._event_listeners
150150 self ._publish = self ._listeners is not None and self ._listeners .enabled_for_server_heartbeat
151151 self ._cancel_context : Optional [_CancellationContext ] = None
152+ self ._conn_id : Optional [int ] = None
152153 self ._rtt_monitor = _RttMonitor (
153154 topology ,
154155 topology_settings ,
@@ -243,6 +244,7 @@ async def _check_server(self) -> ServerDescription:
243244
244245 Returns a ServerDescription.
245246 """
247+ self ._conn_id = None
246248 start = time .monotonic ()
247249 try :
248250 try :
@@ -272,6 +274,7 @@ async def _check_server(self) -> ServerDescription:
272274 awaited = awaited ,
273275 durationMS = duration * 1000 ,
274276 failure = error ,
277+ driverConnectionId = self ._conn_id ,
275278 message = _SDAMStatusMessage .HEARTBEAT_FAIL ,
276279 )
277280 await self ._reset_connection ()
@@ -314,6 +317,8 @@ async def _check_once(self) -> ServerDescription:
314317 )
315318
316319 self ._cancel_context = conn .cancel_context
320+ # Record the connection id so we can later attach it to the failed log message.
321+ self ._conn_id = conn .id
317322 response , round_trip_time = await self ._check_with_socket (conn )
318323 if not response .awaitable :
319324 self ._rtt_monitor .add_sample (round_trip_time )
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ def __init__(
149149 self ._listeners = self ._settings ._pool_options ._event_listeners
150150 self ._publish = self ._listeners is not None and self ._listeners .enabled_for_server_heartbeat
151151 self ._cancel_context : Optional [_CancellationContext ] = None
152+ self ._conn_id : Optional [int ] = None
152153 self ._rtt_monitor = _RttMonitor (
153154 topology ,
154155 topology_settings ,
@@ -243,6 +244,7 @@ def _check_server(self) -> ServerDescription:
243244
244245 Returns a ServerDescription.
245246 """
247+ self ._conn_id = None
246248 start = time .monotonic ()
247249 try :
248250 try :
@@ -272,6 +274,7 @@ def _check_server(self) -> ServerDescription:
272274 awaited = awaited ,
273275 durationMS = duration * 1000 ,
274276 failure = error ,
277+ driverConnectionId = self ._conn_id ,
275278 message = _SDAMStatusMessage .HEARTBEAT_FAIL ,
276279 )
277280 self ._reset_connection ()
@@ -314,6 +317,8 @@ def _check_once(self) -> ServerDescription:
314317 )
315318
316319 self ._cancel_context = conn .cancel_context
320+ # Record the connection id so we can later attach it to the failed log message.
321+ self ._conn_id = conn .id
317322 response , round_trip_time = self ._check_with_socket (conn )
318323 if not response .awaitable :
319324 self ._rtt_monitor .add_sample (round_trip_time )
You can’t perform that action at this time.
0 commit comments