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

feat: expose libcurl timings in the faraday env #7

Merged
merged 4 commits into from
Oct 20, 2023

Conversation

Roguelazer
Copy link
Contributor

This collects all of the detailed timings from libcurl (via Typhoeus) and exposes them as response.env.custom_members[:typhoeus_timings]. We're using this internally, and I thought other folks might find it helpful, too.

Example:

[1] pry(main)> resp = Faraday.new { |b| b.adapter :typhoeus }.get "https://www.example.com"
ETHON: Libcurl initialized
ETHON: performed EASY effective_url=https://www.example.com/ response_code=200 return_code=ok total_time=0.082656
[2] pry(main)> puts resp.env.custom_members[:typhoeus_timings]
{"appconnect"=>0.063223, "connect"=>0.023084, "namelookup"=>0.005523, "pretransfer"=>0.06355, "redirect"=>0.0, "starttransfer"=>0.081755, "total"=>0.082656}

@dleavitt
Copy link
Owner

Thanks, seems legit! Before merging, will probably want to:

  1. Placate Rubocop (which I've just made easier)
  2. Add a smoke test for it, probably about here
  3. Maybe do the :typhoeus_timings keys as symbols instead of strings?

@Roguelazer
Copy link
Contributor Author

Roguelazer commented Oct 14, 2023

@dleavitt eminently-reasonable suggestions; I believe I've done them all, although the smoke test is not very good, since this uses webmock and webmock doesn't expose these fields. I filed bblimke/webmock#1038 to address that, but it looks like there hasn't really been any activity on webmock for a few months...

@dleavitt
Copy link
Owner

Hooray, thanks for the effort! I'll take a look soon.

@dleavitt dleavitt merged commit 17ed8e5 into dleavitt:main Oct 20, 2023
5 checks passed
@Roguelazer Roguelazer deleted the expose-timings branch October 20, 2023 18:18
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

Successfully merging this pull request may close these issues.

2 participants