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

Commit f8e6603

Browse files
committed
added operation cancelled to interceptor
1 parent 8f99e4e commit f8e6603

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
)
2020
from google.cloud.bigtable.data._metrics.data_model import ActiveOperationMetric
2121
from google.cloud.bigtable.data._metrics.data_model import OperationState
22+
from google.cloud.bigtable.data._metrics.handlers._base import MetricsHandler
2223

2324
from google.cloud.bigtable.data._cross_sync import CrossSync
2425

@@ -65,7 +66,7 @@ def wrapper(self, continuation, client_call_details, request):
6566

6667
@CrossSync.convert_class(sync_name="BigtableMetricsInterceptor")
6768
class AsyncBigtableMetricsInterceptor(
68-
UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor
69+
UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor, MetricsHandler
6970
):
7071
"""
7172
An async gRPC interceptor to add client metadata and print server metadata.
@@ -93,8 +94,8 @@ def register_operation(self, operation):
9394
def on_operation_complete(self, op):
9495
del self.operation_map[op.uuid]
9596

96-
def on_attempt_complete(self, attempt, operation):
97-
pass
97+
def on_operation_cancelled(self, op):
98+
self.on_operation_complete(op)
9899

99100
@CrossSync.convert
100101
@_with_operation_from_metadata

google/cloud/bigtable/data/_metrics/data_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def cancel(self):
370370
Called to cancel an operation without processing emitting it.
371371
"""
372372
for handler in self.handlers:
373-
handler.on_operation_canceled(self)
373+
handler.on_operation_cancelled(self)
374374

375375
@staticmethod
376376
def _exc_to_status(exc: Exception) -> StatusCode:

google/cloud/bigtable/data/_metrics/handlers/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, **kwargs):
2929
def on_operation_complete(self, op: CompletedOperationMetric) -> None:
3030
pass
3131

32-
def on_operation_canceled(self, op: ActiveOperationMetric) -> None:
32+
def on_operation_cancelled(self, op: ActiveOperationMetric) -> None:
3333
pass
3434

3535
def on_attempt_complete(

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from google.cloud.bigtable.data._metrics.data_model import ActiveOperationMetric
2323
from google.cloud.bigtable.data._metrics.data_model import OperationState
24+
from google.cloud.bigtable.data._metrics.handlers._base import MetricsHandler
2425
from grpc import UnaryUnaryClientInterceptor
2526
from grpc import UnaryStreamClientInterceptor
2627

@@ -51,7 +52,7 @@ def wrapper(self, continuation, client_call_details, request):
5152

5253

5354
class BigtableMetricsInterceptor(
54-
UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor
55+
UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor, MetricsHandler
5556
):
5657
"""
5758
An async gRPC interceptor to add client metadata and print server metadata.
@@ -77,8 +78,8 @@ def register_operation(self, operation):
7778
def on_operation_complete(self, op):
7879
del self.operation_map[op.uuid]
7980

80-
def on_attempt_complete(self, attempt, operation):
81-
pass
81+
def on_operation_cancelled(self, op):
82+
self.on_operation_complete(op)
8283

8384
@_with_operation_from_metadata
8485
def intercept_unary_unary(

0 commit comments

Comments
 (0)