5252def _restart_on_unavailable (
5353 method ,
5454 request ,
55+ metadata = None ,
5556 trace_name = None ,
5657 session = None ,
5758 attributes = None ,
@@ -96,8 +97,9 @@ def _restart_on_unavailable(
9697 session ,
9798 attributes ,
9899 observability_options = observability_options ,
100+ metadata = metadata ,
99101 ):
100- iterator = method (request = request )
102+ iterator = method (request = request , metadata = metadata )
101103 for item in iterator :
102104 item_buffer .append (item )
103105 # Setting the transaction id because the transaction begin was inlined for first rpc.
@@ -119,6 +121,7 @@ def _restart_on_unavailable(
119121 session ,
120122 attributes ,
121123 observability_options = observability_options ,
124+ metadata = metadata ,
122125 ):
123126 request .resume_token = resume_token
124127 if transaction is not None :
@@ -139,6 +142,7 @@ def _restart_on_unavailable(
139142 session ,
140143 attributes ,
141144 observability_options = observability_options ,
145+ metadata = metadata ,
142146 ):
143147 request .resume_token = resume_token
144148 if transaction is not None :
@@ -340,6 +344,7 @@ def read(
340344 iterator = _restart_on_unavailable (
341345 restart ,
342346 request ,
347+ metadata ,
343348 f"CloudSpanner.{ type (self ).__name__ } .read" ,
344349 self ._session ,
345350 trace_attributes ,
@@ -362,6 +367,7 @@ def read(
362367 iterator = _restart_on_unavailable (
363368 restart ,
364369 request ,
370+ metadata ,
365371 f"CloudSpanner.{ type (self ).__name__ } .read" ,
366372 self ._session ,
367373 trace_attributes ,
@@ -556,6 +562,7 @@ def execute_sql(
556562 return self ._get_streamed_result_set (
557563 restart ,
558564 request ,
565+ metadata ,
559566 trace_attributes ,
560567 column_info ,
561568 observability_options ,
@@ -565,6 +572,7 @@ def execute_sql(
565572 return self ._get_streamed_result_set (
566573 restart ,
567574 request ,
575+ metadata ,
568576 trace_attributes ,
569577 column_info ,
570578 observability_options ,
@@ -575,6 +583,7 @@ def _get_streamed_result_set(
575583 self ,
576584 restart ,
577585 request ,
586+ metadata ,
578587 trace_attributes ,
579588 column_info ,
580589 observability_options = None ,
@@ -583,6 +592,7 @@ def _get_streamed_result_set(
583592 iterator = _restart_on_unavailable (
584593 restart ,
585594 request ,
595+ metadata ,
586596 f"CloudSpanner.{ type (self ).__name__ } .execute_sql" ,
587597 self ._session ,
588598 trace_attributes ,
@@ -689,6 +699,7 @@ def partition_read(
689699 self ._session ,
690700 extra_attributes = trace_attributes ,
691701 observability_options = getattr (database , "observability_options" , None ),
702+ metadata = metadata ,
692703 ):
693704 method = functools .partial (
694705 api .partition_read ,
@@ -792,6 +803,7 @@ def partition_query(
792803 self ._session ,
793804 trace_attributes ,
794805 observability_options = getattr (database , "observability_options" , None ),
806+ metadata = metadata ,
795807 ):
796808 method = functools .partial (
797809 api .partition_query ,
@@ -938,6 +950,7 @@ def begin(self):
938950 f"CloudSpanner.{ type (self ).__name__ } .begin" ,
939951 self ._session ,
940952 observability_options = getattr (database , "observability_options" , None ),
953+ metadata = metadata ,
941954 ):
942955 method = functools .partial (
943956 api .begin_transaction ,
0 commit comments