Allowing for arbitrarily nested dictionaries in _log_entry_mapping_pb.#2589
Allowing for arbitrarily nested dictionaries in _log_entry_mapping_pb.#2589dhermes merged 2 commits intogoogleapis:masterfrom
Conversation
logging/google/cloud/logging/_gax.py
Outdated
| # NOTE: ``json.dumps`` is wasteful here because internally, | ||
| # ``Parse`` will just call ``json.loads``. However, | ||
| # there is no equivalent public function to parse on raw | ||
| # dictionaries, so we waste cycles on parse/unparse. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@dhermes, did you try this on the service and confirm that the data gets logged correctly? |
>>> from google.cloud import logging
>>> client = logging.Client()
>>> logger = client.logger('errors')
>>>
>>> payload = {
... 'a': {
... 'b': 'c',
... }
... }
>>> logger.log_struct(payload)
>>> |
|
@dhermes thanks for figuring this out for me, works for me. As for system test, I think it'd be trivial to add it just by adding one level of nesting to the current log_struct system test. |
Also using ParseDict() instead of Parse() and a wasted json.dumps().
|
@waprin Good find on |
|
LGTM! |
Allowing for arbitrarily nested dictionaries in _log_entry_mapping_pb.
Fixes #2552.
@waprin Do you think it's worthwhile to add a system test for this / update an existing system test with a nested dictionary?