Discriminating timeout reasons with Tesla/hackney

Considering we’re using Tesla & hackney - is there a quick & elegant way of discriminating between {:error, :timeout} that is a TCP connect timeout, versus other reasons of timeout?

What team and myself are currently considering is:

  • write own Tesla.Middleware.Timeout with a special :error, :middleware_timeout
  • write own hackney adapter for tesla, which would use https://github.com/benoitc/hackney#reuse-a-connection when making requests and discriminate between :request_timeout and connect_timeout using this
  • fork hackney and modify there and depend on a forked version

None of these options is really appealing at the moment. (the middleware_timeout is easy to pull off, but doesn’t provide full discrimination).