Add Provider to APICallRecord

Change-Id: I12012bbcfdd28452d7772a5b652716d0c69f5282
This commit is contained in:
Shawn Wang 2020-08-27 16:30:51 -07:00
parent 2774cbd6ac
commit bcb3210760
No known key found for this signature in database
GPG Key ID: C98A86CC967E89A7
3 changed files with 6 additions and 4 deletions

View File

@ -774,7 +774,8 @@ class ClusteredAPI(object):
# add api call log # add api call log
api_record = utils.APICallRecord( 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) endpoint.add_api_record(api_record)
# Adjust API Rate Limit before raising HTTP exception # Adjust API Rate Limit before raising HTTP exception

View File

@ -153,9 +153,9 @@ class NsxLibConfig(object):
The rate has hard max limit of min(100/s, param The rate has hard max limit of min(100/s, param
api_rate_limit_per_endpoint). api_rate_limit_per_endpoint).
:param api_log_mode: Option to collect API call logs within nsxlib. :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. 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. each endpoint will be collected individually.
By default, this option is disabled as set to None. By default, this option is disabled as set to None.

View File

@ -776,11 +776,12 @@ class APIRateLimiterAIMD(APIRateLimiter):
class APICallRecord(object): 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.timestamp = timestamp or time.time()
self.verb = verb self.verb = verb
self.uri = uri self.uri = uri
self.status = status self.status = status
self.provider = provider
class APICallCollector(object): class APICallCollector(object):