Conversation
…nt client is successfully constructed.
| "serviceName": "{{ service.meta.address.proto }}", | ||
| "rpcName": "{{ method_name }}", | ||
| "retryAttempt": 1, | ||
| "request": type(request).to_json(request), |
There was a problem hiding this comment.
Does this request / metadata include request method and request url? We can extract that information out from the http_options defined above.
There was a problem hiding this comment.
No, I didn't include request method or url. We need to add those fields to google-api-core first
https://github.com/googleapis/python-api-core/blob/d18d9b5131162b44eebcc0859a7aca1198a2ac06/google/api_core/client_logging.py#L13-L24
There was a problem hiding this comment.
Do we want the fields to just be part of metadata or request? In that case, adding these fields in google-api-core may not be required.
Adding a TODO comment here linking to an issue would be helpful to understand what's missing.
There was a problem hiding this comment.
The structured logging fields include httpRequest which includes requestMethod and requestUrl.
So we should populate those subfields of httpRequest, which is already registered in api-core.
| if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER | ||
| # TODO: Make this performant when logging is not enabled | ||
|
|
||
| credential_info = None |
There was a problem hiding this comment.
| credential_info = None |
| if "async" not in str(self._transport): | ||
| if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER | ||
|
|
||
| credential_info = None |
There was a problem hiding this comment.
| credential_info = None |
| try: | ||
| from google.api_core import client_logging | ||
| CLIENT_LOGGING_SUPPORTED = True | ||
| except ImportError: | ||
| CLIENT_LOGGING_SUPPORTED = False |
There was a problem hiding this comment.
| try: | |
| from google.api_core import client_logging | |
| CLIENT_LOGGING_SUPPORTED = True | |
| except ImportError: | |
| CLIENT_LOGGING_SUPPORTED = False | |
| try: # pragma: NO COVER | |
| from google.api_core import client_logging. # type: ignore | |
| CLIENT_LOGGING_SUPPORTED = True | |
| except ImportError: | |
| CLIENT_LOGGING_SUPPORTED = False |
| import logging | ||
| _LOGGER = logging.getLogger(__name__) |
There was a problem hiding this comment.
| import logging | |
| _LOGGER = logging.getLogger(__name__) | |
| import logging as std_logging | |
| _LOGGER = std_logging.getLogger(__name__) |
There was a problem hiding this comment.
We don't need std_logging here because we don't directly import any generated types in this file
|
The REST specific changes were moved to a new PR: #2270 |
| is_async (bool): Used to determine the code path i.e. whether for sync or async call. #} | ||
| {% macro rest_call_method_common(body_spec, method_name, service_name, is_async=False) %} | ||
| {% macro rest_call_method_common(body_spec, method_name, service, is_async=False) %} | ||
| {% set service_name = service.name %} |
There was a problem hiding this comment.
nit: Does using service_name instead of service.name in the template buy us anything? They read the same, they're the same number of characters. Does service change in the course of this macro?
| "serviceName": "{{ service.meta.address.proto }}", | ||
| "rpcName": "{{ method_name }}", | ||
| "retryAttempt": 1, | ||
| "request": type(request).to_json(request), |
There was a problem hiding this comment.
The structured logging fields include httpRequest which includes requestMethod and requestUrl.
So we should populate those subfields of httpRequest, which is already registered in api-core.
This PR was built on top of #2265
Example debug logs