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 tracking request-id example #82

Merged
merged 1 commit into from Oct 21, 2020
Merged

Add tracking request-id example #82

merged 1 commit into from Oct 21, 2020

Conversation

vorillaz
Copy link
Contributor

@vorillaz vorillaz commented Mar 4, 2020

Added an example with request tracking as discussed in #80

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

server.register(proxy, {
upstream: 'http://localhost:4001',
replyOptions: {
rewriteRequestHeaders: (originalReq, headers) => ({...headers, 'request-id': uuid()})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a bit more complex than that. This example override the request-id, however we should 1) change the fastify id generator to use the unique id and 2) take it from req.id instead of generating a new one each time.

It would be really nice to have a unit test for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Fastify instance should be configured to read the request id from the incoming header. https://www.fastify.io/docs/v2.12.x/Server/#requestidheader

@stale
Copy link

stale bot commented Oct 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 21, 2020
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@stale stale bot removed the stale label Oct 21, 2020
@mcollina mcollina merged commit eb60ec2 into fastify:master Oct 21, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants