Skip to content

Commit dba0bf0

Browse files
committed
PYTHON-5993 Clarify the operation_telemetry docstrings
Carries the wording from PR 1 forward and corrects it for the behavior this branch adds: both cursor types pass a span now, and what one covers is a single caller-driven getMore rather than a run of them.
1 parent 0d0e244 commit dba0bf0

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

pymongo/asynchronous/mongo_client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,8 +1912,10 @@ async def _run_operation(
19121912
:param address: Optional address when sending a message
19131913
to a specific server, used for getMore.
19141914
:param operation_telemetry: The operation span created by the calling
1915-
cursor (see ``AsyncCursor._refresh``), or None. Passed down so the
1916-
command spans of this send nest under it.
1915+
cursor (see ``AsyncCursor._refresh``), or None. Covers a single
1916+
caller-driven getMore, or the whole of a public API call that
1917+
drains the cursor itself. Passed down so the command spans of this
1918+
send nest under it.
19171919
:param reuse_current_span: Create no operation span at all and leave the
19181920
ambient span in place as the parent for this operation's command
19191921
spans. Mutually exclusive with ``operation_telemetry``. Defaults to
@@ -2027,12 +2029,13 @@ async def _retry_internal(
20272029
:param is_aggregate_write: If this is a aggregate operation with a write, defaults to False.
20282030
:param operation_id: Stable operation id shared across retries, defaults to None
20292031
:param operation_telemetry: An operation span the caller created and will
2030-
end itself, defaults to None. Only ``AsyncCursor`` passes one (see
2031-
``AsyncCursor._refresh``): its span has to survive send paths that
2032-
bypass this method, so the cursor ends it rather than this call.
2033-
Given a span, this method neither creates nor ends one and only
2034-
makes the caller's current for the duration of the call; given
2035-
None, it creates a span and ends it before returning.
2032+
end itself, defaults to None. Cursors pass one (see
2033+
``AsyncCursor._refresh`` and ``AsyncCommandCursor._refresh``): the
2034+
span has to survive send paths that bypass this method, so the
2035+
cursor ends it rather than this call. Given a span, this method
2036+
neither creates nor ends one and only makes the caller's current
2037+
for the duration of the call; given None, it creates a span and
2038+
ends it before returning.
20362039
:param reuse_current_span: Create no operation span at all and leave the
20372040
ambient span in place as the parent for this operation's command
20382041
spans. For callers that know a suitable operation span is already

pymongo/synchronous/mongo_client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,8 +1907,10 @@ def _run_operation(
19071907
:param address: Optional address when sending a message
19081908
to a specific server, used for getMore.
19091909
:param operation_telemetry: The operation span created by the calling
1910-
cursor (see ``Cursor._refresh``), or None. Passed down so the
1911-
command spans of this send nest under it.
1910+
cursor (see ``Cursor._refresh``), or None. Covers a single
1911+
caller-driven getMore, or the whole of a public API call that
1912+
drains the cursor itself. Passed down so the command spans of this
1913+
send nest under it.
19121914
:param reuse_current_span: Create no operation span at all and leave the
19131915
ambient span in place as the parent for this operation's command
19141916
spans. Mutually exclusive with ``operation_telemetry``. Defaults to
@@ -2022,12 +2024,13 @@ def _retry_internal(
20222024
:param is_aggregate_write: If this is a aggregate operation with a write, defaults to False.
20232025
:param operation_id: Stable operation id shared across retries, defaults to None
20242026
:param operation_telemetry: An operation span the caller created and will
2025-
end itself, defaults to None. Only ``Cursor`` passes one (see
2026-
``Cursor._refresh``): its span has to survive send paths that
2027-
bypass this method, so the cursor ends it rather than this call.
2028-
Given a span, this method neither creates nor ends one and only
2029-
makes the caller's current for the duration of the call; given
2030-
None, it creates a span and ends it before returning.
2027+
end itself, defaults to None. Cursors pass one (see
2028+
``Cursor._refresh`` and ``CommandCursor._refresh``): the
2029+
span has to survive send paths that bypass this method, so the
2030+
cursor ends it rather than this call. Given a span, this method
2031+
neither creates nor ends one and only makes the caller's current
2032+
for the duration of the call; given None, it creates a span and
2033+
ends it before returning.
20312034
:param reuse_current_span: Create no operation span at all and leave the
20322035
ambient span in place as the parent for this operation's command
20332036
spans. For callers that know a suitable operation span is already

0 commit comments

Comments
 (0)