.NET Core 中如何生成 HttpContext TraceIdentifier? [英] How is HttpContext TraceIdentifier generated in .NET Core?
问题描述
HttpContext TraceIdentifier(又名 Correlation-Id)是如何生成的?
How is HttpContext TraceIdentifier (aka Correlation-Id) generated?
我通过控制器请求一个页面,它给了我以下 TraceId:0HLEACIU86PT6:0000000D
I request a page through controller which gives me the following TraceId:
0HLEACIU86PT6:0000000D
页面触发了一个具有以下 TraceId 的 ajax 调用:0HLEACIU86PT7:00000005
The page fires an ajax call which has the following TraceId:
0HLEACIU86PT7:00000005
如您所见,它们非常相似.是按时间计算的吗?
As you can see, they are very similar. Is it based on time?
为什么我没有得到相同的 TraceIdentifier?
Why didn't I get the same TraceIdentifier?
如何确保相同的 TraceIdentifier?
How can I ensure the same TraceIdentifier?
推荐答案
Kestrel 将请求 ID 生成为 {ConnectionId}:{Request number}.连接 ID 是使用字母表 1-9 和 A - V 的 long 的 base32 编码版本.请求计数是通过该连接的请求数.通过特定连接的第 n 个请求是 {ConnectionId}:{n}
Kestrel generates the request ID as {ConnectionId}:{Request number}. The connection id is the base32 encoded version of a long using the alphabet 1-9, and A - V. The request count is the number of requests over that connection. The nth request over a specific connection is {ConnectionId}:{n}
这篇关于.NET Core 中如何生成 HttpContext TraceIdentifier?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!