From 81d8a8715589b99659f2a95f57e3d27f008e2139 Mon Sep 17 00:00:00 2001 From: Shawn Wang Date: Thu, 27 Aug 2020 16:30:51 -0700 Subject: [PATCH] Add Provider to APICallRecord Change-Id: I12012bbcfdd28452d7772a5b652716d0c69f5282 (cherry picked from commit bcb32107600ef55f5a342229ff541b0022f3184a) --- vmware_nsxlib/v3/cluster.py | 3 ++- vmware_nsxlib/v3/config.py | 4 ++-- vmware_nsxlib/v3/utils.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vmware_nsxlib/v3/cluster.py b/vmware_nsxlib/v3/cluster.py index d10f965d..8facbe6a 100644 --- a/vmware_nsxlib/v3/cluster.py +++ b/vmware_nsxlib/v3/cluster.py @@ -771,7 +771,8 @@ class ClusteredAPI(object): # add api call log api_record = utils.APICallRecord( - verb=proxy_for, uri=uri, status=response.status_code) + verb=proxy_for, uri=uri, status=response.status_code, + provider=endpoint.provider.id) endpoint.add_api_record(api_record) # Adjust API Rate Limit before raising HTTP exception diff --git a/vmware_nsxlib/v3/config.py b/vmware_nsxlib/v3/config.py index c1036c48..806f9800 100644 --- a/vmware_nsxlib/v3/config.py +++ b/vmware_nsxlib/v3/config.py @@ -153,9 +153,9 @@ class NsxLibConfig(object): The rate has hard max limit of min(100/s, param api_rate_limit_per_endpoint). :param api_log_mode: Option to collect API call logs within nsxlib. - When set to API_LOG_PER_CLUSTER, API call sent to all + When set to API_LOG_PER_CLUSTER, API calls sent to all endpoints will be collected at one place. - When set to API_LOG_PER_ENDPOINT, API call sent to + When set to API_LOG_PER_ENDPOINT, API calls sent to each endpoint will be collected individually. By default, this option is disabled as set to None. diff --git a/vmware_nsxlib/v3/utils.py b/vmware_nsxlib/v3/utils.py index ddfeeb52..a024fd62 100644 --- a/vmware_nsxlib/v3/utils.py +++ b/vmware_nsxlib/v3/utils.py @@ -776,11 +776,12 @@ class APIRateLimiterAIMD(APIRateLimiter): class APICallRecord(object): - def __init__(self, verb, uri, status, timestamp=None): + def __init__(self, verb, uri, status, provider=None, timestamp=None): self.timestamp = timestamp or time.time() self.verb = verb self.uri = uri self.status = status + self.provider = provider class APICallCollector(object):