diff --git a/google/cloud/spanner_v1/database.py b/google/cloud/spanner_v1/database.py index bb279611a6..38ac469fe3 100644 --- a/google/cloud/spanner_v1/database.py +++ b/google/cloud/spanner_v1/database.py @@ -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) @@ -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)()