'How to pass traceId generated in a service to another with Nestjs TCP call

I have a service(A) act as the entry point which receives HTTP request, it is able to retrieve/create a traceID for each single call, and call another service (B) via TCP (message pattern).

For logging purpose, how to pass this traceID pass from A to B? I am not expecting to use data besides the cmd, it does not look too neat. Is there any technique could achieve this?



Solution 1:[1]

Resolved this by sending the traceId as an extra field in the data. Service B parse the tranceId then.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chun Young