Fork me on GitHub
#aleph
<
2019-03-27
>
valerauko09:03:11

is anyone using new relic with aleph?

pithyless13:03:02

@UAEH11THP You may want to ask @seancorfield (who is not in this channel) if you have questions about instrumenting NewRelic.

igrishaev14:03:32

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]
     ...)))

mccraigmccraig23:03:43

@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

mccraigmccraig23:03:45

I'm afk atm, I'll try and post some code tomorrow if that would be helpful