On 27 July 2015 at 08:28, crocket <crockabisc...@gmail.com> wrote: > Can I see your proof of concept on github? Is it just an idea? >
Well, my first attempt at this was Inquest: https://github.com/weavejester/inquest The idea of Inquest was to (ab)use alter-var-root to insert monitoring into existing functions, but I quickly discovered that there were quite a few anonymous functions I would like to monitor, as well as specific variables inside functions. I played around with ways of wrapping functions to inject monitoring of arguments and return values, but in the end it felt too clumsy and complicated. So instead, I've been considering a macro like: (monitor key & body) For example, if you wrote: (let [x 10] (monitor :user/example (inc x))) This would produce messages that look like this: {:tag :user/example :timestamp 468822291902146 :thread-id 1502 :namespace user :event :enter :form (inc x) :locals {x 10}} {:tag :user/example :timestamp 468822291902261 :thread-id 1502 :namespace user :event :exit :form (inc x) :locals {x 10} :return 11 :duration 115} These messages would be passed to any listeners interested in the tag :user/example. If there were no appropriate listeners, the macro would execute the code without any additional wrapping. I've also been considering having the listeners declare ahead of time what keys they're interested in, as some keys might be expensive to generate (e.g. a :stacktrace key). The upshot is that you'd get a whole bunch of information that you could then narrow down to produce any output you happen to want. If you're not interested in listening to a particular monitor, then there's minimal performance impact (perhaps around 50ns). - James -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.