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).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s