Dropping .elapsed
in favor of event hooks.
#3012
Unanswered
tomchristie
asked this question in
General
Replies: 1 comment
-
Some contexts of |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently we have a
response.elapsed
API built-in, which uses some slightly odd mechanics under-the-hood.It's also not especially useful as it only monitors the metric of "time between request send and response close".
Since we're focused on simplicity of the stack throughout, I'm proposing here that we consider dropping this.
In it's place I'm suggesting that we adapt the request hooks slightly to include a
'close'
event, and allow developers to add request timing themselves if required.We would...
BoundSyncStream
/BoundAsyncStream
.Timer
.Request.elapsed
public API.And...
'close'
event hook.event_hooks
as a request extension, in order to implement firing a'close'
event from the response.We'd include a documentation example that would be something like this...
Using this approach developers can time either or both of "time until response returned" (using the
'response'
event hook) / "time until response body read to completion" (using the'close'
event hook).We probably also end up with a side-effect here of supporting per-request event hooks. (Eg. see #2991)
There's also scope for us to consider how this could tie in with the
'trace'
extension for finer grained metrics.Beta Was this translation helpful? Give feedback.
All reactions