-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gracefully continue if LogEntry.proto_payload type URL is not in registry. #3270
Conversation
""" | ||
try: | ||
return MessageToDict(entry_pb) | ||
except TypeError: |
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.
@@ -270,11 +272,13 @@ def sink_update(self, project, sink_name, filter_, destination): | |||
path = 'projects/%s/sinks/%s' % (project, sink_name) | |||
sink_pb = LogSink(name=path, filter=filter_, destination=destination) | |||
try: | |||
self._gax_api.update_sink(path, sink_pb, options=options) | |||
sink_pb = self._gax_api.update_sink(path, sink_pb, options=options) |
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.
@@ -418,11 +424,14 @@ def metric_update(self, project, metric_name, filter_, description): | |||
metric_pb = LogMetric(name=path, filter=filter_, | |||
description=description) | |||
try: | |||
self._gax_api.update_log_metric(path, metric_pb, options=options) | |||
metric_pb = self._gax_api.update_log_metric( |
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.
@@ -293,7 +293,7 @@ def sink_update(self, project, sink_name, filter_, destination): | |||
'filter': filter_, | |||
'destination': destination, | |||
} | |||
self.api_request(method='PUT', path=target, data=data) | |||
return self.api_request(method='PUT', path=target, data=data) |
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.
@@ -428,7 +428,7 @@ def metric_update(self, project, metric_name, filter_, description): | |||
'filter': filter_, | |||
'description': description, | |||
} | |||
self.api_request(method='PUT', path=target, data=data) | |||
return self.api_request(method='PUT', path=target, data=data) |
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.
@@ -74,7 +77,13 @@ class _BaseEntry(object): | |||
""" | |||
def __init__(self, payload, logger, insert_id=None, timestamp=None, | |||
labels=None, severity=None, http_request=None): | |||
self.payload = payload | |||
if isinstance(payload, any_pb2.Any): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I will try to get this over the line today if I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL @lukesneeringer (and @tseaver and anyone else interested in this PR)
@@ -270,11 +272,13 @@ def sink_update(self, project, sink_name, filter_, destination): | |||
path = 'projects/%s/sinks/%s' % (project, sink_name) | |||
sink_pb = LogSink(name=path, filter=filter_, destination=destination) | |||
try: | |||
self._gax_api.update_sink(path, sink_pb, options=options) | |||
sink_pb = self._gax_api.update_sink(path, sink_pb, options=options) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
self.payload_pb = self.payload | ||
self.payload = None | ||
else: | ||
self.payload_pb = None |
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.
self.assertIsNone(protobuf_entry.payload) | ||
self.assertIsInstance(protobuf_entry.payload_pb, any_pb2.Any) | ||
self.assertEqual(protobuf_entry.payload_pb.type_url, type_url) | ||
else: |
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.
@@ -108,6 +108,7 @@ class TestLogging(unittest.TestCase): | |||
'precipitation': False, | |||
}, | |||
} | |||
TYPE_FILTER = 'protoPayload.@type = "{}"' |
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.
filter_ = self.TYPE_FILTER.format(type_url) | ||
entry_iter = iter( | ||
Config.CLIENT.list_entries(page_size=1, filter_=filter_)) | ||
protobuf_entry = next(entry_iter) |
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.
logging/tests/unit/test__gax.py
Outdated
}, | ||
'requestTime': { | ||
'seconds': 1491000125, | ||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
logging/tests/unit/test__gax.py
Outdated
'requestTime': { | ||
'seconds': 1491000125, | ||
} | ||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@tseaver @lukesneeringer Do you have any issues? @waprin Can you vet my newly added system test? |
No issues. Approved. |
@dhermes tied up today but can review your tests and try to make mine less flaky (and loop back to any other pending issues for me in this repo) tomorrow. |
@dhermes sorry for delay, nice PR. One quick note about the system test - I think it's fine but in general the gotcha to be aware of with Logging is that you can get an empty page followed by a page with results. The nextPageToken is used as a sort of "pending" sign (not a fan of this but that's how it works). So in theory |
@waprin I'll be on the lookout for that if there is a flaky failure. |
…stry. (googleapis#3270) * Gracefully continue if LogEntry.proto_payload type URL is not in registry. Fixes googleapis#2674. * Adding unit / system tests for "graceful" continuation on LogEntry parsing. * Docs fix for PR 3270. * Adding rtype/returns to metric_update and sink_update in logging _http module. * Add trailing commas.
Fixes #2674.
@lukesneeringer @tseaver I am unfortunately "out of time" until Wednesday so if either of you want to take this over the finish line (e.g. unit tests and maybe a system test with an unregistered type URL?) I would not protest.