Skip to content

Commit

Permalink
Database.execute_pdml: add events for before and after BeginTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Nov 20, 2024
1 parent 71e14c4 commit 1102709
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions google/cloud/spanner_v1/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,16 @@ def execute_partitioned_dml(
)

def execute_pdml():
def do_execute_pdml(session):
def do_execute_pdml(session, span):
if span:
span.add_event("Starting BeginTransaction")
txn = api.begin_transaction(
session=session.name, options=txn_options, metadata=metadata
)
if span:
span.add_event(
"Completed BeginTransaction", {"transaction.id": txn.id}
)

txn_selector = TransactionSelector(id=txn.id)

Expand Down Expand Up @@ -735,9 +741,9 @@ def do_execute_pdml(session):
"CloudSpanner.execute_partitioned_pdml",
None,
observability_options=observability_options,
):
) as span:
with SessionCheckout(self._pool) as session:
return do_execute_pdml(session)
return do_execute_pdml(session, span)

return _retry_on_aborted(execute_pdml, DEFAULT_RETRY_BACKOFF)()

Expand Down

0 comments on commit 1102709

Please sign in to comment.