Skip to content

Commit 488c750

Browse files
committed
PYTHON-5846 Add comments explaining unconditional start time recording in _CmapTelemetry
1 parent de14677 commit 488c750

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

pymongo/_telemetry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ def pool_closed(self) -> None:
283283
self._listeners.publish_pool_closed(self._address)
284284

285285
def connection_created(self, conn_id: int) -> None:
286+
# Always record start time: logging or publishing may be enabled by the time
287+
# connection_ready is called to compute the duration.
286288
self._conn_created_start = time.monotonic()
287289
# Log before publishing to prevent potential listener preemption in tests.
288290
if self._should_log:
@@ -325,6 +327,8 @@ def connection_closed(self, conn_id: int, reason: str) -> None:
325327
def checkout_started(self) -> None:
326328
should_log = self._should_log
327329
should_publish = self._should_publish
330+
# Always record start time: logging or publishing may be enabled by the time
331+
# checkout_succeeded or checkout_failed is called to compute the duration.
328332
self._checkout_start = time.monotonic()
329333
if should_publish:
330334
assert self._listeners is not None

0 commit comments

Comments
 (0)