Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 67b78c6

Browse files
1 parent 146f11a commit 67b78c6

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

google/cloud/spanner_v1/session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ def create(self):
174174
request.session.labels = self._labels
175175

176176
observability_options = getattr(self._database, "observability_options", None)
177-
span_name = "CloudSpanner.CreateMultiplexedSession" if self._is_multiplexed else "CloudSpanner.CreateSession"
177+
span_name = (
178+
"CloudSpanner.CreateMultiplexedSession"
179+
if self._is_multiplexed
180+
else "CloudSpanner.CreateSession"
181+
)
178182
with trace_call(
179183
span_name,
180184
self,

tests/system/test_session_api.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -688,30 +688,30 @@ def transaction_work(transaction):
688688
# - run_in_transaction uses regular sessions (GetSession)
689689
# - Snapshot (read-only) can use multiplexed sessions (CreateMultiplexedSession)
690690
want_span_names = [
691-
"CloudSpanner.GetSession", # Batch operation
692-
"CloudSpanner.Batch.commit", # Batch commit
693-
"CloudSpanner.GetSession", # Transaction session
694-
"CloudSpanner.Transaction.read", # First read
695-
"CloudSpanner.Transaction.read", # Second read
696-
"CloudSpanner.Transaction.rollback", # Rollback due to exception
697-
"CloudSpanner.Session.run_in_transaction", # Session transaction wrapper
698-
"CloudSpanner.Database.run_in_transaction", # Database transaction wrapper
699-
"CloudSpanner.CreateMultiplexedSession", # Snapshot session (read-only)
700-
"CloudSpanner.Snapshot.read", # Snapshot read
691+
"CloudSpanner.GetSession", # Batch operation
692+
"CloudSpanner.Batch.commit", # Batch commit
693+
"CloudSpanner.GetSession", # Transaction session
694+
"CloudSpanner.Transaction.read", # First read
695+
"CloudSpanner.Transaction.read", # Second read
696+
"CloudSpanner.Transaction.rollback", # Rollback due to exception
697+
"CloudSpanner.Session.run_in_transaction", # Session transaction wrapper
698+
"CloudSpanner.Database.run_in_transaction", # Database transaction wrapper
699+
"CloudSpanner.CreateMultiplexedSession", # Snapshot session (read-only)
700+
"CloudSpanner.Snapshot.read", # Snapshot read
701701
]
702702
else:
703703
# Without multiplexed sessions, all operations use regular sessions
704704
want_span_names = [
705-
"CloudSpanner.GetSession", # Batch operation
706-
"CloudSpanner.Batch.commit", # Batch commit
707-
"CloudSpanner.GetSession", # Transaction session
708-
"CloudSpanner.Transaction.read", # First read
709-
"CloudSpanner.Transaction.read", # Second read
710-
"CloudSpanner.Transaction.rollback", # Rollback due to exception
711-
"CloudSpanner.Session.run_in_transaction", # Session transaction wrapper
712-
"CloudSpanner.Database.run_in_transaction", # Database transaction wrapper
713-
"CloudSpanner.GetSession", # Snapshot session
714-
"CloudSpanner.Snapshot.read", # Snapshot read
705+
"CloudSpanner.GetSession", # Batch operation
706+
"CloudSpanner.Batch.commit", # Batch commit
707+
"CloudSpanner.GetSession", # Transaction session
708+
"CloudSpanner.Transaction.read", # First read
709+
"CloudSpanner.Transaction.read", # Second read
710+
"CloudSpanner.Transaction.rollback", # Rollback due to exception
711+
"CloudSpanner.Session.run_in_transaction", # Session transaction wrapper
712+
"CloudSpanner.Database.run_in_transaction", # Database transaction wrapper
713+
"CloudSpanner.GetSession", # Snapshot session
714+
"CloudSpanner.Snapshot.read", # Snapshot read
715715
]
716716

717717
assert got_span_names == want_span_names
@@ -820,14 +820,18 @@ def transaction_work(transaction):
820820
# For multiplexed sessions, don't include session_found attribute
821821
snapshot_session_attributes = _make_attributes(
822822
db_name,
823-
x_goog_spanner_request_id=span_list[8].attributes["x_goog_spanner_request_id"],
823+
x_goog_spanner_request_id=span_list[8].attributes[
824+
"x_goog_spanner_request_id"
825+
],
824826
)
825827
else:
826828
expected_snapshot_span_name = "CloudSpanner.GetSession"
827829
snapshot_session_attributes = _make_attributes(
828830
db_name,
829831
session_found=True,
830-
x_goog_spanner_request_id=span_list[8].attributes["x_goog_spanner_request_id"],
832+
x_goog_spanner_request_id=span_list[8].attributes[
833+
"x_goog_spanner_request_id"
834+
],
831835
)
832836

833837
assert_span_attributes(
@@ -845,7 +849,9 @@ def transaction_work(transaction):
845849
db_name,
846850
table_id=sd.TABLE,
847851
columns=sd.COLUMNS,
848-
x_goog_spanner_request_id=span_list[9].attributes["x_goog_spanner_request_id"],
852+
x_goog_spanner_request_id=span_list[9].attributes[
853+
"x_goog_spanner_request_id"
854+
],
849855
),
850856
span=span_list[9],
851857
)

0 commit comments

Comments
 (0)