DamianEdwards/MinimalApiPlayground

Some sample API implemented in .Net 6.0 using minimal API with customized OpenApi support:

  • a playground with different test cases of miminal API possibilities (Results, custom IResults, advanced binding, etc…),
  • a classical TODO Api in EF Core,
  • a classical TODO Api in Dapper,

with validation support using System.ComponentModel.Validation extended by MinimalApis.Extensions (for now in preview).

Tomasz Pęczek repositories

Tomasz GitHub is a gem of asp.Net core related stuff:

Each subject is largely explain in understandable but not simplistic blog posts (and often very advanced technically) . Multiples sample projects are present. A very educational approach that makes you want to dig deeper.

Server Timing during API calls

Today, I was looking Developer Tools in Chrome to understand some request duration. My request takes more than 10 secondes :

10 seconds seems very long but but Timing tab don’t give me why. I suddenly saw the bottom part of this screen:

I don’t know if it’s a recent addition or if it’s been around for a long time, whatever, it looks promising. The link provided is not particularily interesting for me because its focus is mainly on browser part but it gives me a cue: a response header called “Server-Timing”.

Like always, some googling gives me a W3C working draft complete but not too much user friendly and a more understandable Server-Timing on MDN. This”Server-Timing” header is what I was missing. A standardized way of producing detailed information about the duration of what happened while processing the request. An Chrome is able to show them very easily. Perfect.

Some more search gives me a blog post (C# – How to add request timings to an ASP.Net project) about a pretty good implementation in .Net tpeczek/Lib.AspNetCore.ServerTiming in GitHub. A service to produce metrics and a middleware to write the now famous “Server-Timing” header. Clean!

Of course, for security reasons, it’s best to restrict the production of these metrics to some environments (perhaps internals only) or even to specifics clients (it could be restricted to authenticated users with some claims).