is anyone using new relic with aleph?
@vale You may want to ask @seancorfield
(who is not in this channel) if you have questions about instrumenting NewRelic.
Hi! When sending an HTTP request with aleph, I prefer to wrap http/get
into a future. This is to catch some possible exceptions related to a malformed URL, for example. One of my teammates noticed that such a structure consumes two threads that probably leads to a bottleneck. It it really so?
clojure
(->
(d/future
(http/get url))
(d/chain
(fn [response]
(let [{:keys [headers]} response
content-length (get headers "content-length")]
...)))
(d/catch
(fn [^Exception e]
...)))
@igrishaev http/get
is non-blocking, while d/future
uses a thread, so isn't a good wrapper for http/get
. if you are seeing exceptions before the first callback of http/get
, what I've done in similar circumstances is use a macro which wraps its body in a d/catch
and a try ... catch
and ensures you always get a Deferred
result
I'm afk atm, I'll try and post some code tomorrow if that would be helpful