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

Docs: req.id #59

Open
OliverJAsh opened this issue Feb 27, 2019 · 1 comment
Open

Docs: req.id #59

OliverJAsh opened this issue Feb 27, 2019 · 1 comment

Comments

@OliverJAsh
Copy link

This module reads from req.id:

return req.id || (nextReqId = (nextReqId + 1) & maxInt)

However this property doesn't seem to be documented anywhere. It's not something provided by Express, for example.

Could we add some docs to specify what this is for and how to use it along with this module? I suspect it can be used like this:

app.use((req, _res, next) => {
  req.id = req.get('x-request-id');
  next();
});

app.use(expressPinoLogger);

Then Pino will infer the request ID from the req.id we defined.

The same thing can be achieved with the genReqId option, however this also overrides the fallback for when x-request-id/req.id is not defined, which is not always desired. (For context, we want to use x-request-id when it's defined, otherwise use Pino's own request IDs.)

@mcollina
Copy link
Member

Feel free to send a PR with the docs, it would be handy!

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

No branches or pull requests

2 participants