Application Insights 请求遥测中如何测量请求的持续时间?
How is the duration of a request measured in Application Insights Request Telemetry?
在我的 ASP.NET 核心应用程序中,Request Telemetry 会自动记录到 Application Insights,这很棒。但最好知道持续时间是如何测量的。想必某处有个“秒表”,但它什么时候开始,什么时候停止呢?持续时间包括什么?我想更深入地了解这是如何完成的。
asp.net核心中有两部分请求跟踪。
- asp.net 核心本身具有利用 .net 核心内置 System.Diagnostics 跟踪的诊断跟踪。简单来说,它在 HTTP 请求管道的不同阶段捕获 activities/events 比方说 Request-start、Request-stop 等。所以这是能够捕获我们需要跟踪的内容的第一步请求。
- 现在加入 Application Insights asp.net 核心集成。当您 enable Application Insights in your asp.net core application, it initializes several inbuilt Telemetry Modules. One of those is RequestTrackingTelemetryModule which hooks up to a DiagnosticListener 捕获我们在上面 #1 中讨论的请求 start/stop 事件时。是的,它使用秒表来计算请求开始和停止之间的差异。
顺便说一句,app insights sdk and asp.net core 是开源的,以供您探索 in-depth。
在我的 ASP.NET 核心应用程序中,Request Telemetry 会自动记录到 Application Insights,这很棒。但最好知道持续时间是如何测量的。想必某处有个“秒表”,但它什么时候开始,什么时候停止呢?持续时间包括什么?我想更深入地了解这是如何完成的。
asp.net核心中有两部分请求跟踪。
- asp.net 核心本身具有利用 .net 核心内置 System.Diagnostics 跟踪的诊断跟踪。简单来说,它在 HTTP 请求管道的不同阶段捕获 activities/events 比方说 Request-start、Request-stop 等。所以这是能够捕获我们需要跟踪的内容的第一步请求。
- 现在加入 Application Insights asp.net 核心集成。当您 enable Application Insights in your asp.net core application, it initializes several inbuilt Telemetry Modules. One of those is RequestTrackingTelemetryModule which hooks up to a DiagnosticListener 捕获我们在上面 #1 中讨论的请求 start/stop 事件时。是的,它使用秒表来计算请求开始和停止之间的差异。
顺便说一句,app insights sdk and asp.net core 是开源的,以供您探索 in-depth。