|
|
@ -118,6 +118,9 @@ _global_rpcs_started: Mapping[str, int] = collections.defaultdict(int) |
|
|
|
_global_rpcs_succeeded: Mapping[str, int] = collections.defaultdict(int) |
|
|
|
_global_rpcs_succeeded: Mapping[str, int] = collections.defaultdict(int) |
|
|
|
_global_rpcs_failed: Mapping[str, int] = collections.defaultdict(int) |
|
|
|
_global_rpcs_failed: Mapping[str, int] = collections.defaultdict(int) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Mapping[method, Mapping[status_code, count]] |
|
|
|
|
|
|
|
_global_rpc_statuses: Mapping[str, Mapping[int, int]] = collections.defaultdict(lambda: collections.defaultdict(int)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _handle_sigint(sig, frame) -> None: |
|
|
|
def _handle_sigint(sig, frame) -> None: |
|
|
|
_stop_event.set() |
|
|
|
_stop_event.set() |
|
|
@ -163,6 +166,9 @@ class _LoadBalancerStatsServicer(test_pb2_grpc.LoadBalancerStatsServiceServicer |
|
|
|
caps_method] = _global_rpcs_succeeded[method] |
|
|
|
caps_method] = _global_rpcs_succeeded[method] |
|
|
|
response.num_rpcs_failed_by_method[ |
|
|
|
response.num_rpcs_failed_by_method[ |
|
|
|
caps_method] = _global_rpcs_failed[method] |
|
|
|
caps_method] = _global_rpcs_failed[method] |
|
|
|
|
|
|
|
response.stats_per_method[caps_method].rpcs_started = _global_rpcs_started[method] |
|
|
|
|
|
|
|
for code, count in _global_rpc_statuses[method].items(): |
|
|
|
|
|
|
|
response.stats_per_method[caps_method].result[code] = count |
|
|
|
logger.info("Returning cumulative stats response.") |
|
|
|
logger.info("Returning cumulative stats response.") |
|
|
|
return response |
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
@ -189,6 +195,7 @@ def _on_rpc_done(rpc_id: int, future: grpc.Future, method: str, |
|
|
|
print_response: bool) -> None: |
|
|
|
print_response: bool) -> None: |
|
|
|
exception = future.exception() |
|
|
|
exception = future.exception() |
|
|
|
hostname = "" |
|
|
|
hostname = "" |
|
|
|
|
|
|
|
_global_rpc_statuses[method][future.code().value[0]] += 1 |
|
|
|
if exception is not None: |
|
|
|
if exception is not None: |
|
|
|
with _global_lock: |
|
|
|
with _global_lock: |
|
|
|
_global_rpcs_failed[method] += 1 |
|
|
|
_global_rpcs_failed[method] += 1 |
|
|
@ -399,6 +406,8 @@ def parse_rpc_arg(rpc_arg: str) -> Sequence[str]: |
|
|
|
", ".join(_SUPPORTED_METHODS))) |
|
|
|
", ".join(_SUPPORTED_METHODS))) |
|
|
|
return methods |
|
|
|
return methods |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resp = messages_pb2.LoadBalancerAccumulatedStatsResponse() |
|
|
|
|
|
|
|
resp.stats_per_method["/method1"].result[2] = 11 |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
parser = argparse.ArgumentParser( |
|
|
|
parser = argparse.ArgumentParser( |
|
|
|