@@ -104,11 +104,14 @@ def _restart_on_unavailable(
104104 attributes ,
105105 observability_options = observability_options ,
106106 metadata = metadata ,
107- ), MetricsCapture ():
107+ ) as span , MetricsCapture ():
108108 iterator = method (
109109 request = request ,
110110 metadata = request_id_manager .metadata_with_request_id (
111- nth_request , attempt , metadata
111+ nth_request ,
112+ attempt ,
113+ metadata ,
114+ span ,
112115 ),
113116 )
114117 for item in iterator :
@@ -133,7 +136,7 @@ def _restart_on_unavailable(
133136 attributes ,
134137 observability_options = observability_options ,
135138 metadata = metadata ,
136- ), MetricsCapture ():
139+ ) as span , MetricsCapture ():
137140 request .resume_token = resume_token
138141 if transaction is not None :
139142 transaction_selector = transaction ._make_txn_selector ()
@@ -142,7 +145,10 @@ def _restart_on_unavailable(
142145 iterator = method (
143146 request = request ,
144147 metadata = request_id_manager .metadata_with_request_id (
145- nth_request , attempt , metadata
148+ nth_request ,
149+ attempt ,
150+ metadata ,
151+ span ,
146152 ),
147153 )
148154 continue
@@ -160,7 +166,7 @@ def _restart_on_unavailable(
160166 attributes ,
161167 observability_options = observability_options ,
162168 metadata = metadata ,
163- ), MetricsCapture ():
169+ ) as span , MetricsCapture ():
164170 request .resume_token = resume_token
165171 if transaction is not None :
166172 transaction_selector = transaction ._make_txn_selector ()
@@ -169,7 +175,10 @@ def _restart_on_unavailable(
169175 iterator = method (
170176 request = request ,
171177 metadata = request_id_manager .metadata_with_request_id (
172- nth_request , attempt , metadata
178+ nth_request ,
179+ attempt ,
180+ metadata ,
181+ span ,
173182 ),
174183 )
175184 continue
@@ -745,13 +754,16 @@ def partition_read(
745754 extra_attributes = trace_attributes ,
746755 observability_options = getattr (database , "observability_options" , None ),
747756 metadata = metadata ,
748- ), MetricsCapture ():
757+ ) as span , MetricsCapture ():
749758 nth_request = getattr (database , "_next_nth_request" , 0 )
750759 attempt = AtomicCounter ()
751760
752761 def attempt_tracking_method ():
753762 all_metadata = database .metadata_with_request_id (
754- nth_request , attempt .increment (), metadata
763+ nth_request ,
764+ attempt .increment (),
765+ metadata ,
766+ span ,
755767 )
756768 method = functools .partial (
757769 api .partition_read ,
@@ -858,13 +870,16 @@ def partition_query(
858870 trace_attributes ,
859871 observability_options = getattr (database , "observability_options" , None ),
860872 metadata = metadata ,
861- ), MetricsCapture ():
873+ ) as span , MetricsCapture ():
862874 nth_request = getattr (database , "_next_nth_request" , 0 )
863875 attempt = AtomicCounter ()
864876
865877 def attempt_tracking_method ():
866878 all_metadata = database .metadata_with_request_id (
867- nth_request , attempt .increment (), metadata
879+ nth_request ,
880+ attempt .increment (),
881+ metadata ,
882+ span ,
868883 )
869884 method = functools .partial (
870885 api .partition_query ,
@@ -1014,13 +1029,16 @@ def begin(self):
10141029 self ._session ,
10151030 observability_options = getattr (database , "observability_options" , None ),
10161031 metadata = metadata ,
1017- ), MetricsCapture ():
1032+ ) as span , MetricsCapture ():
10181033 nth_request = getattr (database , "_next_nth_request" , 0 )
10191034 attempt = AtomicCounter ()
10201035
10211036 def attempt_tracking_method ():
10221037 all_metadata = database .metadata_with_request_id (
1023- nth_request , attempt .increment (), metadata
1038+ nth_request ,
1039+ attempt .increment (),
1040+ metadata ,
1041+ span ,
10241042 )
10251043 method = functools .partial (
10261044 api .begin_transaction ,
0 commit comments