Extract request timing in a global response filter

I was wondering if anyone has experimented with injecting timing data into the response header? When using the request log feature, each request is timed and added to the log; however, I would like to be able to “read” that timing data in a GlobalResponse filter and add it to a custom header.

That way when consuming API requests, I can get a sense of server-side execution time excluding any network/transport related timing.

Doable built-in, or would I have to manually add a timer via the global request filters?

Never mind - got it. Found that you’re setting a stopwatch item in the request directly, then reading it back. Works.

Curious to dig more into the timing though … for example, Chrome may report “waiting” as 100 ms, but I’m logging 45 ms, with a timer inserted in PreRequest Filter and stopping in GlobalResponse. Might try going further to the edges, say HTTP Handler and OnEndRequest.

1 Like