我正在测试跟踪在 ASP.NET Core 3.1 中的工作方式,但有些东西不起作用。我有 3 个启用了 ActivityIdFormat.W3C 的 ASP.NET Core 应用程序(Node1、Node2、Node3),并且调用层次结构是使用 httpclient 的 Node1->Node2->Node3。当调用 Node2 时,它具有正确的 ParentId,它等于来自 Node1 的 SpanId。但是当从 Node2 ParentId 调用 Node3 时是错误的。在每个节点的日志下方 - 您可以看到我还转储了标头,看起来从 Node2 发送的标头是错误的。我在 .NET 5 中看到了相同的行为,但是当我签入没有 ActivityIdFormat.W3C 的 .NET 3.1 时,父级会在所有节点上传播。
{
"@t": "2021-03-03T14:14:28.1125178Z",
"@mt": "Test on Node 1 with {@Headers}",
"@l": "Error",
"Headers": "[Connection, keep-alive], [Accept, */*], [Accept-Encoding, gzip, deflate, br], [Host, localhost:5001], [Referer, http://localhost:5000/WeatherForecast?test=three], [User-Agent, PostmanRuntime/7.26.10], [Postman-Token, 566e895a-efc9-440d-9cc2-d3272a59f08e]",
"SourceContext": "TraceTest.Controllers.WeatherForecastController",
"ActionId": "8322cc4b-f499-4292-ad92-95edf9932274",
"ActionName": "TraceTest.Controllers.WeatherForecastController.Get (TraceTest)",
"RequestId": "0HM6U9QJT75QA:00000001",
"RequestPath": "/WeatherForecast",
"SpanId": "c0e4e78f0ab2684f",
"TraceId": "532c5503c7def848953038f49ba81918",
"ParentId": "0000000000000000",
"ConnectionId": "0HM6U9QJT75QA"
}
{
"@t": "2021-03-03T14:14:28.5933479Z",
"@mt": "Test on Node 2 with {@Headers}",
"@l": "Error",
"Headers": "[Host, localhost:5011], [traceparent, 00-532c5503c7def848953038f49ba81918-c0e4e78f0ab2684f-00]",
"SourceContext": "TraceTest.Controllers.WeatherForecastController",
"ActionId": "47ec867a-b69b-49bf-91d2-4aeb089fe7d6",
"ActionName": "TraceTest.Controllers.WeatherForecastController.Get (TraceTestNode2)",
"RequestId": "0HM6U9QK2GI54:00000001",
"RequestPath": "/WeatherForecast",
"SpanId": "65583073c1fa3644",
"TraceId": "532c5503c7def848953038f49ba81918",
"ParentId": "c0e4e78f0ab2684f",
"ConnectionId": "0HM6U9QK2GI54"
}
{
"@t": "2021-03-03T14:14:29.0369082Z",
"@mt": "Test on Node 3 with {@Headers}",
"@l": "Error",
"Headers": "[Host, localhost:5021], [traceparent, 00-532c5503c7def848953038f49ba81918-ffcefa1bb1710340-00]",
"SourceContext": "TraceTest.Controllers.WeatherForecastController",
"ActionId": "c475354c-ba74-4f45-b9d4-57362a3b8899",
"ActionName": "TraceTest.Controllers.WeatherForecastController.Get (TraceTestNode3)",
"RequestId": "0HM6U9QK6QAPH:00000001",
"RequestPath": "/WeatherForecast",
"SpanId": "262cbf3f566d9044",
"TraceId": "532c5503c7def848953038f49ba81918",
"ParentId": "ffcefa1bb1710340",
"ConnectionId": "0HM6U9QK6QAPH"
}
源代码可以在这里找到https://github.com/dominikjeske/Samples/tree/main/TraceTest