Skip to content

Commit 58e966b

Browse files
committed
PYTHON-5846 Only record heartbeat start time when logging or publishing is enabled
1 parent 488c750 commit 58e966b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

pymongo/_telemetry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ def _emit_log(self, message: _SDAMStatusMessage, **extra: Any) -> None:
425425

426426
def started(self) -> None:
427427
"""Publish the APM heartbeat-started event (before connection checkout)."""
428-
self._start = time.monotonic()
428+
if self._should_publish or self._should_log:
429+
self._start = time.monotonic()
429430
if self._should_publish:
430431
assert self._listeners is not None
431432
self._listeners.publish_server_heartbeat_started(self._address, self._awaited)

0 commit comments

Comments
 (0)