Skip to content

Set record.message to ensure msg is shown in the Stackdriver UI#7

Merged
mlazarov merged 6 commits into
mlazarov:masterfrom
Binarytales:master
Feb 9, 2017
Merged

Set record.message to ensure msg is shown in the Stackdriver UI#7
mlazarov merged 6 commits into
mlazarov:masterfrom
Binarytales:master

Conversation

@Binarytales
Copy link
Copy Markdown
Contributor

This is quite a small change and there may be a better or more idiomatic way to achieve this but I found that this change was need to change this:

screen shot 2017-02-03 at 11 43 10

to this:

screen shot 2017-02-03 at 11 43 32

@zbjornson
Copy link
Copy Markdown
Collaborator

LGTM. (For clarity, it's Bunyan and not this or express-bunyan that set the msg property: https://github.com/trentm/node-bunyan/blob/master/lib/bunyan.js#L1000.)

@Binarytales
Copy link
Copy Markdown
Contributor Author

Thanks for the "LGTM" @zbjornson. Yes I came across that and combined with the line here: https://github.com/trentm/node-bunyan/blob/master/lib/bunyan.js#L963

...makes it so that this can't be worked around even with a custom error serialiser.

Let me know if there is anything more I can do to help ensure this can be merged.

@mlazarov
Copy link
Copy Markdown
Owner

mlazarov commented Feb 6, 2017

LGTM
Please add version bump to package.json. My suggestion is 1.3.0 as this improvement makes significant change of the behavior.

Stackdriver/Google error reporting requires that error logs have a V8 stacktrace as the payload `message`: https://cloud.google.com/error-reporting/docs/formatting-error-messages

They also require setting a service context (`"serviceContext": {"service": "worker"}`) but this can be done in serialisers or on Bunyan loggers themselves
@Binarytales
Copy link
Copy Markdown
Contributor Author

Binarytales commented Feb 6, 2017

I've made an additional change to this PR that looks for an error on record.err and if present sets the record.message to be record.err.stack.

This is required by the Google Stackdriver Error Reporting functionallity for automatically pulling error logs from the logging service into the error reporting service.

There are some additional required properties for this functionallity but these are able to be set from on a logger or applied via a serialiser (and the source of the values will be application specific) so I have not included them here.

Let me know what you think, I'm happy to revert this additional change if it moves too far away from the original intent of this stream plugin.

I have also bumped the version number as requested.

UPDATE: Thinking about it a bit more, perhaps when there is a record.err it should test if there was already a record.message and move that to something like record.originalMessage so it is retained, I worry though that that would be starting to make too many assumptions about the original log/record fields.

Also, perhaps the record.msg and record.error should be deleted from the record after they are moved to the record.message (depending on which ones happens. I welcome any and all feedback.

@zbjornson
Copy link
Copy Markdown
Collaborator

It would be awesome to have your observations about where these fields show up in the Stackdriver interface documented in the readme since I don't think they're in Google's docs, maybe even including the additional fields that you mentioned.

I would only assign the message to err.stackif stack is defined.

@Binarytales
Copy link
Copy Markdown
Contributor Author

@zbjornson I have made the requested changes. Let me know if the addition to the Readme wasn't what you had in mind.

And thank you again for taking the time to review and consider this PR.

@mlazarov
Copy link
Copy Markdown
Owner

mlazarov commented Feb 9, 2017

LGTM.

@zbjornson
Copy link
Copy Markdown
Collaborator

Me too! Thanks @Binarytales

@mlazarov mlazarov merged commit d8af691 into mlazarov:master Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants