Einar
Einar

Reputation: 312

How is the duration of a request measured in Application Insights Request Telemetry?

In my ASP.NET Core application, Request Telemetry is automatically logged to Application Insights, which is wonderful. But it would be nice to know exactly how the duration is measured. Presumably there is a "stopwatch" somewhere, but when does it start and when does it stop? What's included in the duration? I'd like more insight into exactly how this is done.

Upvotes: 0

Views: 2674

Answers (1)

krishg
krishg

Reputation: 6508

There are two parts of the request tracing in asp.net core.

  1. asp.net core itself has Diagnostic tracing which leverages .net core inbuilt System.Diagnostics tracing. In simple terms, it captures activities/events during different stages in the HTTP request pipeline let's say Request-start, Request-stop etc. So this is the first step of being able to capture what we need to track requests.
  2. Now coming to Application Insights asp.net core integration. When you 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 to capture request start/stop events we talked in #1 above. Yes, it uses stopwatch to calculate difference between request start and stop.

By the way, app insights sdk and asp.net core are opensource in case you want to explorer in-depth.

Upvotes: 1

Related Questions