-
Notifications
You must be signed in to change notification settings - Fork 360
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
Add request ID fields to all DB and auth logs #2683
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.
LGTM - wrote about one concern I have with WithContext
} | ||
return logging.Default() | ||
return log.WithContext(ctx).WithFields(fields) |
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.
General concern - not knowing when to call WithContext - looks like it is something we need to load on our logger as soon as possible or defer it to the last thing we do.
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.
I believe this is the right place to do it. I changed the signature of getLogger
to say you need to know the context in which you will be logging. So as soon as you need it, you must give context and additional fields. Now outputting a bad DB log without context and/or fields is actually more difficult than outputting a good one :-)
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.
Thanks!
} | ||
return logging.Default() | ||
return log.WithContext(ctx).WithFields(fields) |
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.
I believe this is the right place to do it. I changed the signature of getLogger
to say you need to know the context in which you will be logging. So as soon as you need it, you must give context and additional fields. Now outputting a bad DB log without context and/or fields is actually more difficult than outputting a good one :-)
Partly of #2682. Most important gap is causing AWS clients (and, less
crucially, Azure and GCP) to log the request ID.