-
Notifications
You must be signed in to change notification settings - Fork 0
Logging: Add request id to the app logs for easy log tracking #68
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
const asyncStorage = new AsyncLocalStorage<RequestMetadata>(); | ||
|
||
// Gets the RequestMetadada object associated with the current request | ||
export function getStore(): RequestMetadata { |
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.
high
correctness
The getStore
function returns a RequestMetadata
object with an empty requestId
if the store is undefined. This could lead to logs with missing request IDs, which may defeat the purpose of tracking requests. Consider initializing with a new nanoid
instead.
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 is happening only for "root"-level logging - and is expected - they are not part of any request.
Prepends a nanoid as the requestId to each log so it's easier to track down all the requests for a specific request. eg:
