puzpuzpuz / cls-rtracer

Request Tracer - CLS-based request id generation for Express, Fastify, Koa and Hapi, batteries included
MIT License
311 stars 24 forks source link

Question about multiple request #65

Closed TannerS closed 2 years ago

TannerS commented 2 years ago

This may be a dumb question, but i just wanted to be sure that if a route gets hit by x number of users at the same time (or you know, possibly very close cause we cant always recreate a real world scenario) that the trace ids will be different per question and its not depended on when u define/initial the library or specific to the folder.

thank you

puzpuzpuz commented 2 years ago

Yes, each HTTP request should get its own unique id.

TannerS commented 2 years ago

got it, i assume its per application instance is how this works, a singleton design ? or am I wrong? :)

puzpuzpuz commented 2 years ago

The context is bound to each particular HTTP request, not Express instance or anything like that. Of course, if you have multiple Express applications running in the same Node.js process, each of them needs to register the middleware.

puzpuzpuz commented 2 years ago

Closing this one since as answered. Feel free to reopen if you have more questions.