SHARE:

ASP.NET Core 8: Expose Timestamp data request processing with IHttpSysRequestTimingFeature when using HTTP.sys

Introduction

ASP.NET Core 8 is quite there and brings some improvements in performance diagnostics! In this post I will show how to collect detailed timestamp data related to request processing when using HTTP.sys with the new interface IHttpSysRequestTimingFeature.

The IHttpSysRequestTimingFeature interface

The new IHttpSysRequestTimingFeature exposes three methods as follow:

  • Timestamps: Gets a collection of timestamps in which each index of the collection define a value of HttpSysRequestTimingType enum. It corresponds to the type of request processing timestamp. Each value is timestamp.
  • TryGetTimestamp: Allows to retrieve a timestamp for a given type of request processing
  • TryGetElapsedTime: Allows to compute the time elapsed between two types of request processing.

The following code shows an usage example of the IHttpSysRequestTimingFeature interface and HttpSysRequestTimingType enum:

Since I’m not using HTTP/2, HTTP/3 and TLS, timestamps related to these request processing are returning 0. I’m getting there the time elapsed between the ConnectionStart request processing type and RequestDeliveredForIO request processing type. as You can see 465 micro seconds elapsed:

As Microsoft says, this enhancement provide multiple benefit such as:

  • More granular insight into the various stages of request processing.
  • Precise performance diagnostics capabilities.
  • Improved access to and control over HTTP.sys request timing data.

Source: https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-8-preview-5/#ihttpsysrequesttimingfeature

Interesting isn’t it ? 😉

Written by

anthonygiretti

Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.