Skip to content
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

Merged
merged 1 commit into from
Nov 10, 2021

Conversation

arielshaqed
Copy link
Contributor

@arielshaqed arielshaqed commented Nov 10, 2021

Partly of #2682. Most important gap is causing AWS clients (and, less
crucially, Azure and GCP) to log the request ID.

@arielshaqed arielshaqed requested a review from nopcoder November 10, 2021 06:38
@arielshaqed arielshaqed added the include-changelog PR description should be included in next release changelog label Nov 10, 2021
Copy link
Contributor

@nopcoder nopcoder left a 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)
Copy link
Contributor

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.

Copy link
Contributor Author

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 :-)

Copy link
Contributor Author

@arielshaqed arielshaqed left a 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)
Copy link
Contributor Author

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 :-)

@arielshaqed arielshaqed merged commit df12f17 into master Nov 10, 2021
@arielshaqed arielshaqed deleted the chore/moar-request-ids branch November 10, 2021 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants