PYTHON-6035 Add OpenTelemetry transaction spans - #2992
Draft
blink1073 wants to merge 1 commit into
Draft
Conversation
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 17, 2026 22:39
1c0a690 to
1852427
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 17, 2026 22:50
1852427 to
e6cb0d5
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 17, 2026 23:09
e6cb0d5 to
820fb1d
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 01:40
820fb1d to
0c73147
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 01:54
0c73147 to
c936c5a
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 02:06
c936c5a to
55eae9c
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 10:22
55eae9c to
252d25e
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 10:29
252d25e to
36c501e
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 10:44
36c501e to
b70f3b6
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
2 times, most recently
from
August 18, 2026 11:06
39d9eaa to
cb1d5c5
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 11:18
cb1d5c5 to
96daee2
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 11:42
96daee2 to
2a7a131
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 11:50
2a7a131 to
bf998fc
Compare
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 12:02
bf998fc to
7f50b68
Compare
Wrap a transaction's operation spans in a "transaction" pseudo-span, per the OpenTelemetry driver specification. The span is stored on the session's _Transaction and passed as the explicit parent when an operation span starts, rather than read from ambient context, so a concurrently running unrelated session cannot pick up this transaction by accident. with_transaction() pins one span across all of its retries, so a retried call still yields a single span rather than one per attempt. Its retry loop moves into a helper to keep the span bookkeeping readable. A nested with_transaction() call on the same session now raises instead of clobbering and leaking the outer call's span, and a direct-API commit retry starts a fresh span, the previous attempt having already ended its own.
blink1073
force-pushed
the
PYTHON-5947-otel-2-transactions
branch
from
August 18, 2026 12:55
7f50b68 to
b5dee1f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PYTHON-6035
Second of four PRs splitting #2964. Base is
PYTHON-5947-otel-1-operations.PYTHON-5947-otel-1-operationsPYTHON-5947-otel-2-transactionsPYTHON-5947-otel-3-unifiedPYTHON-5947-otel-4-getmoreChanges in this PR
Wraps a transaction's operation spans in a
"transaction"span, per the OpenTelemetry driver specification, so the operations belonging to one transaction group under it instead of appearing as unrelated siblings."transaction"span coversstart_transaction()throughcommit_transaction()/abort_transaction(), with the operations inside nested under it.with_transaction()produces one span for the whole call rather than one per attempt.with_transaction()call on the same session now raisesInvalidOperationinstead of leaking the outer call's span.with_transaction's retry loop moves into a helper to keep the span handling readable; diffing with whitespace ignored shows the loop body untouched.Test Plan
with_transactionretries, retried commits, early-return commit and abort paths, spans across two sessions, and the nested-call guard.test_transactions.pyand PR 1's 98 otel tests.just lintclean.Transaction spans only run on a replica set, which PR 1's expanded Evergreen variant covers in full.
Checklist
Checklist for Author
Checklist for Reviewer