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

Commit 50b3e48

Browse files
committed
remove operation metadata key
1 parent bd9ab70 commit 50b3e48

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

google/cloud/bigtable/data/_async/metrics_interceptor.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,22 @@ def _with_operation_from_metadata(func):
4343

4444
@wraps(func)
4545
def wrapper(self, continuation, client_call_details, request):
46-
key = next(
47-
(
48-
m[1]
49-
for m in client_call_details.metadata
50-
if m[0] == OPERATION_INTERCEPTOR_METADATA_KEY
51-
),
52-
None,
53-
)
54-
operation: "ActiveOperationMetric" = self.operation_map.get(key)
46+
found_operation_id: str | None = None
47+
new_metadata = client_call_details.metadata
48+
if client_call_details.metadata:
49+
# find operation key and strip it from metadata
50+
temp_metadata = []
51+
for k, v in client_call_details.metadata:
52+
if k == OPERATION_INTERCEPTOR_METADATA_KEY:
53+
found_operation_id = v
54+
else:
55+
temp_metadata.append((k, v))
56+
new_metadata = temp_metadata
57+
58+
operation: "ActiveOperationMetric" = self.operation_map.get(found_operation_id)
5559
if operation:
60+
# create new client_call_details without the operation key
61+
client_call_details = client_call_details._replace(metadata=new_metadata)
5662
# start a new attempt if not started
5763
if (
5864
operation.state == OperationState.CREATED

0 commit comments

Comments
 (0)