@@ -50,7 +50,7 @@ class _BatchBase(_SessionWrapper):
5050 def __init__ (self , session ):
5151 super (_BatchBase , self ).__init__ (session )
5252 self ._mutations = []
53- self .__span = trace_call_end_lazily (
53+ self .__discard_span = trace_call_end_lazily (
5454 f"CloudSpanner.{ type (self ).__name__ } " ,
5555 self ._session ,
5656 None ,
@@ -82,7 +82,6 @@ def insert(self, table, columns, values):
8282 add_event_on_current_span (
8383 "insert mutations added" ,
8484 dict (table = table , columns = columns ),
85- self .__span ,
8685 )
8786 self ._mutations .append (Mutation (insert = _make_write_pb (table , columns , values )))
8887
@@ -102,7 +101,6 @@ def update(self, table, columns, values):
102101 add_event_on_current_span (
103102 "update mutations added" ,
104103 dict (table = table , columns = columns ),
105- self .__span ,
106104 )
107105
108106 def insert_or_update (self , table , columns , values ):
@@ -123,7 +121,6 @@ def insert_or_update(self, table, columns, values):
123121 add_event_on_current_span (
124122 "insert_or_update mutations added" ,
125123 dict (table = table , columns = columns ),
126- self .__span ,
127124 )
128125
129126 def replace (self , table , columns , values ):
@@ -140,7 +137,8 @@ def replace(self, table, columns, values):
140137 """
141138 self ._mutations .append (Mutation (replace = _make_write_pb (table , columns , values )))
142139 add_event_on_current_span (
143- "replace mutations added" , dict (table = table , columns = columns ), self .__span
140+ "replace mutations added" ,
141+ dict (table = table , columns = columns ),
144142 )
145143
146144 def delete (self , table , keyset ):
@@ -155,7 +153,8 @@ def delete(self, table, keyset):
155153 delete = Mutation .Delete (table = table , key_set = keyset ._to_pb ())
156154 self ._mutations .append (Mutation (delete = delete ))
157155 add_event_on_current_span (
158- "delete mutations added" , dict (table = table ), self .__span
156+ "delete mutations added" ,
157+ dict (table = table ),
159158 )
160159
161160
@@ -262,7 +261,7 @@ def __enter__(self):
262261 observability_options = getattr (
263262 self ._session ._database , "observability_options" , None
264263 )
265- self .__span = trace_call_end_lazily (
264+ self .__discard_span = trace_call_end_lazily (
266265 "CloudSpanner.Batch" ,
267266 self ._session ,
268267 observability_options = observability_options ,
@@ -274,9 +273,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
274273 """End ``with`` block."""
275274 if exc_type is None :
276275 self .commit ()
277- if self .__span :
278- self .__span . end ( )
279- self .__span = None
276+ if self .__discard_span :
277+ self .__discard_span ( exc_type , exc_val , exc_tb )
278+ self .__discard_span = None
280279
281280
282281class MutationGroup (_BatchBase ):
0 commit comments