Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add way to measure request duration if retry is enabled #16

Open
rpaterson opened this issue Jan 13, 2020 · 1 comment
Open

Comments

@rpaterson
Copy link

What / Why

I want to measure how long successful requests take, in order to calibrate my timeout so that only the slowest 5% of requests time out. If retry is disabled that's easy - simply record Date.now() before calling fetch() and then subtract it from Date.now() after the response is received. However if retry is enabled I can't figure out a way to measure the duration of the ultimately successful try.

The onRetry() callback is invoked before the sleep for the retry delay, so there's no way to measure how long the request actually took without including the retry delay, especially if the randomize retry option is enabled.

When

When retry is enabled

Where

  • n/a

How

Current Behavior

No way to measure successful request try duration if there were retries.

Expected Behavior

Somehow I would like this to be possible. For example perhaps we could add duration or startedAt to the returned response object?

Who

  • n/a

References

  • n/a
@rpaterson
Copy link
Author

Just noticed the x-fetch-attempts header - something like that could work as an interface for this - e.g. a new header x-fetch-started-at or x-fetch-duration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@rpaterson and others