-
Notifications
You must be signed in to change notification settings - Fork 139
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
feat(gcf-utils): add trigger info as bindings to all log statements #796
feat(gcf-utils): add trigger info as bindings to all log statements #796
Conversation
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.
This looks good to me, could you give me an example in the issue body of what the log message ends up looking like?
packages/gcf-utils/src/gcf-utils.ts
Outdated
const triggerInfo = buildTriggerInfo(triggerType, id, request.body); | ||
logger.metric(triggerInfo); | ||
|
||
delete triggerInfo.message; // we don't want to bind the message to every log entry | ||
GCFBootstrapper.bindPropertiesToLogger(triggerInfo); |
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.
Could we make buildTriggerInfo
not include message
, set the logger to the child logger, then do logger.metric("message originally in buildTriggerInfo")
?
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.
You mean like this?
const triggerInfo = buildTriggerInfo(triggerType, id, request.body);
GCFBootstrapper.bindPropertiesToLogger(triggerInfo); // no message in triggerInfo
logger.metric({
message: `Execution started by ${triggerType}`,
...triggerInfo
});
This works too!
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.
Since the trigger info should already be added to all the log entries, you should only have to call
logger.metric(`Execution started by ${triggerType}`);
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.
ahh ok ok - makes sense
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.
done!
Your PR has attempted to merge for 3 hours. Please check that all required checks have passed, you have an automerge label, and that all your reviewers have approved the PR |
🤖 I have created a release \*beep\* \*boop\* --- ## [5.5.0](https://www.github.com/googleapis/repo-automation-bots/compare/v5.4.0...v5.5.0) (2020-08-05) ### Features * **gcf-utils:** add trigger info as bindings to all log statements ([#796](https://www.github.com/googleapis/repo-automation-bots/issues/796)) ([157c768](https://www.github.com/googleapis/repo-automation-bots/commit/157c768e6de8e3067e24a6dd17be152ae98c25d8)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
…ements (googleapis#796)" This reverts commit 157c768.
…oogleapis#796) * feat(gcf-utils): add trigger info as bindings to all log statements * don't recreate logger to attach bindings * move deletion of message prop to main gcf method * move trigger message addition to gcf-bootstrapper * remove extra trigger info logging Co-authored-by: Jeff Ching <chingor@google.com>
Resulting log statements will look something like this:
Fixes #777