May I know whats the difference between uuid and correlation-id npm packages? correlation-id internally using uuid package only..
In what scenario correlation-id is much better to use than uuid?
Note:
Am not using nodejs in my application, instead using Java as my Backend, and using Angular as Front end, While making request, I need to pass some header with some unique value, then which package should I prefer in angular?: correlation-id or uuid?
CodePudding user response:
The underlying implementation generates a uuid.
The core difference is that it can return the same uuid if called from the same context - for e.g correlator.withId method mentioned in documentation returns the same uuid.
correlation-id is used in request logging. For ex. Express has a middleware which attaches a unique correlation-id to each request which can be obtained using req.correlationId().
If called from anywhere where the req object is present it will return the same correlation-id. Hence it can trace a particular request.
CodePudding user response:
- If you want unique identifiers for your server objects, you can use
uuid. - If you want to keep track of a chain of functions calls of each request in your node server,
correlation-idcan help with that.
Except having id in the name, they are different. correlation-id can use uuid to generate ids that can be used to uniquely identify an async call chain.
