I am not clear which id header I should put in the request and response for the correlationship purpose.
\"X-Correlation-ID\" and the \"X-Request-ID\" are the known http
For Request-Id
, it's uniquely identifies every HTTP request involved in operation processing, and is generated on the caller side and passed to callee.
For X-Correlation-ID
, also known as a Transit ID, is a unique identifier value that is attached to requests and messages that allow reference to a particular transaction or event chain.
For every request, you should use Request-Id
, for request transaction, you should use X-Correlation-ID
.
If I don't use the Activity, I don't need to send that header, right?
For Correlation ID, in general, you don’t have to use one. But if you are designing a distributed system that incorporates message queues and asynchronous processing, you will do well to include a Correlation ID in your messages.
I find the Activity.Current is always null. Does it need to be enabled and does it affect performance?
For using Activity.Current
, you need to able ApplicationInsights
, or implement your own feature to manage activity.
Microsoft.ApplicationInsights.AspNetCore
WebHost.CreateDefaultBuilder(args).UseStartup().UseApplicationInsights()
var activity = Activity.Current;