@@ -68,11 +68,12 @@ def reset(self):
68
68
69
69
70
70
X_GOOG_REQUEST_ID = "x-goog-spanner-request-id"
71
- # TODO:(@odeke-em): delete this guard when PR #1367 is merged.
72
- __X_GOOG_REQUEST_ID_FUNCTIONALITY_MERGED = False
73
71
74
72
75
73
class XGoogRequestIDHeaderInterceptor (ClientInterceptor ):
74
+ # TODO:(@odeke-em): delete this guard when PR #1367 is merged.
75
+ X_GOOG_REQUEST_ID_FUNCTIONALITY_MERGED = False
76
+
76
77
def __init__ (self ):
77
78
self ._unary_req_segments = []
78
79
self ._stream_req_segments = []
@@ -86,22 +87,24 @@ def intercept(self, method, request_or_iterator, call_details):
86
87
x_goog_request_id = value
87
88
break
88
89
89
- if __X_GOOG_REQUEST_ID_FUNCTIONALITY_MERGED and not x_goog_request_id :
90
+ if self . X_GOOG_REQUEST_ID_FUNCTIONALITY_MERGED and not x_goog_request_id :
90
91
raise Exception (
91
92
f"Missing { X_GOOG_REQUEST_ID } header in { call_details .method } "
92
93
)
93
94
94
95
response_or_iterator = method (request_or_iterator , call_details )
95
96
streaming = getattr (response_or_iterator , "__iter__" , None ) is not None
96
- with self .__lock :
97
- if streaming :
98
- self ._stream_req_segments .append (
99
- (call_details .method , parse_request_id (x_goog_request_id ))
100
- )
101
- else :
102
- self ._unary_req_segments .append (
103
- (call_details .method , parse_request_id (x_goog_request_id ))
104
- )
97
+
98
+ if self .X_GOOG_REQUEST_ID_FUNCTIONALITY_MERGED :
99
+ with self .__lock :
100
+ if streaming :
101
+ self ._stream_req_segments .append (
102
+ (call_details .method , parse_request_id (x_goog_request_id ))
103
+ )
104
+ else :
105
+ self ._unary_req_segments .append (
106
+ (call_details .method , parse_request_id (x_goog_request_id ))
107
+ )
105
108
106
109
return response_or_iterator
107
110
0 commit comments