This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-20
Channels
- # aws (1)
- # beginners (14)
- # boot (30)
- # cider (6)
- # clara (9)
- # cljsjs (3)
- # cljsrn (22)
- # clojure (247)
- # clojure-dusseldorf (75)
- # clojure-france (38)
- # clojure-italy (6)
- # clojure-japan (8)
- # clojure-nl (3)
- # clojure-russia (16)
- # clojure-serbia (4)
- # clojure-spec (1)
- # clojure-uk (53)
- # clojurescript (168)
- # consulting (3)
- # copenhagen-clojurians (1)
- # core-async (7)
- # css (1)
- # datascript (3)
- # datomic (8)
- # dirac (22)
- # events (1)
- # hoplon (2)
- # jobs (1)
- # jobs-discuss (2)
- # leiningen (4)
- # lumo (138)
- # mount (13)
- # nyc (1)
- # off-topic (24)
- # om (34)
- # onyx (15)
- # pedestal (30)
- # re-frame (9)
- # reagent (23)
- # ring (1)
- # ring-swagger (24)
- # rum (6)
- # spacemacs (6)
- # specter (51)
- # uncomplicate (14)
- # unrepl (1)
- # untangled (17)
- # yada (12)
so I'm finding lots of use cases for interceptor chains in some data processing code I'm writing
I'd like to re-use io.pedestal.interceptor for this if possible, but one of the primary things I would like is a way to instrument each :enter and :leave function so I can compute stats about how long the chain takes and what is slowing it down
so far I don't see an obvious hook in the source where I can wrap each interceptor ... could I be missing something?
when you construct an interceptor, the :enter
and :leave
impls are just functions. wrap them with a higher-order fn that keeps track of timing. But it might be better to implement a stateful interceptor
You can create a record that implements the IntoInterceptor
protocol https://github.com/pedestal/pedestal/blob/master/interceptor/src/io/pedestal/interceptor.clj#L23
@hagmonk I'll also put in a plug for the pedestal.log module as a way to convey the metrics out of the process
well, I don't want to get you too excited... the interceptor chain provider doesn't track metrics. that is still up to your interceptors.
yes, but you’re free to emit metrics using pedestal.log
from your lifecycle implementations
given that, I’d use a higher-order fn which does that and wraps the :enter/:leave
impls
it seems to use dropwizard which is perfect, the wrapper looks nicer than metrics-clojure anyway
so I could create an interceptor chain, then map a wrapper fn that handles metrics over that
Of course I’m designing this off the top of my head. The key insight is to use pedestal.log
’s metric support
I'm executing this chain on top of an Apache Ignite cluster so I'm pondering if I can capitalize on that somehow
I've been musing on this idea for general Clojure functions, but maybe interceptors are a better context. That idea was attaching metadata to functions that simply says "time how long this takes", or "attach this Failsafe policy", or "rename the thread of execution inside this function"