-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Allow turning on JSON Detection in StackDriver #6293
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
Conversation
} | ||
|
||
if self._include_logger_name: | ||
log_record['info']['python_logger'] = record.name |
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.
@@ -230,7 +236,7 @@ def _main_thread_terminated(self): | ||
file=sys.stderr) | ||
|
||
def enqueue(self, record, message, resource=None, labels=None, | ||
trace=None, span_id=None): | ||
trace=None, span_id=None, include_logger_name=True): |
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.
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.
We need test coverage for the case where the user disables adding the logger name.
To enable JSON detection in StackDriver, `jsonPayload` should have no fields other than `message`. This patch lets clients opt-in to this behavior, by creating a custom Transport. Fixes #5799
@tseaver added tests and they seem to pass! |
This patch sends events (currently, just launches) to stackdriver. The events aren't parsed as JSON by stackdriver yet, but that should be fixed by googleapis/google-cloud-python#6293. You can find the events under 'Global -> binderhub-events-text'.
@crwilcox I found linting errors from @kokoro-team, and pushed a fix! Thanks |
I missed one lint failure, fixed now. Would be easier if lint ran on CircleCI or something earlier. |
Hi @yuvipanda . Thanks for the PR. Something 'funny' is going on with the test runs on GitHub right now. You should see a series of tests happening for this, but none are showing. We will need to sort that out before merging. |
@crwilcox are these the @kokoro-team tests or something else? Anything I can do? |
@@ -166,15 +166,17 @@ def test_constructor(self): | ||
grace_period = 50 | ||
max_batch_size = 50 | ||
max_latency = 0.1 | ||
include_logger_name = True |
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.
|
||
worker = self._make_one( | ||
logger, grace_period=grace_period, max_batch_size=max_batch_size, | ||
max_latency=max_latency) | ||
max_latency=max_latency, include_logger_name=include_logger_name) |
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.assertEqual(worker._cloud_logger, logger) | ||
self.assertEqual(worker._grace_period, grace_period) | ||
self.assertEqual(worker._max_batch_size, max_batch_size) | ||
self.assertEqual(worker._max_latency, max_latency) | ||
self.assertEqual(worker._include_logger_name, include_logger_name) |
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.
@crwilcox I believe your comments have been addressed. CI is green, so merge when ready. |
Thank you @yuvipanda for the contribution! |
Includes googleapis/google-cloud-python#6293. Lets us push structured logs to stackdriver, rather than textual logs.
To enable JSON detection in StackDriver,
jsonPayload
shouldhave no fields other than
message
. This patch lets clientsopt-in to this behavior, by creating a custom Transport.
Fixes #5799