Should I use Request-Id, X-Request-Id or X-Correlation-Id in the request header?

前端 未结 1 994
北海茫月
北海茫月 2021-02-07 15:15

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

相关标签:
1条回答
  • 2021-02-07 16:08

    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.

    1. Install Microsoft.ApplicationInsights.AspNetCore
    2. Configure WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().UseApplicationInsights()
    3. Use like var activity = Activity.Current;
    0 讨论(0)
提交回复
热议问题