Show errors when they occurs

This commit is contained in:
Yann Esposito 2015-03-23 08:57:43 +01:00
parent 4f429f5463
commit 64891674e1
3 changed files with 25 additions and 7 deletions

View file

@ -159,6 +159,11 @@ Sometime you might want to get the maximum of some values during an interval of
That will display `{:foo 5}` in the resume.
## Open Issue
Sending a really huge number of timer events could lead to a stack overflow.
Just add more size to your stack `-Xss16m`.
## License
Copyright © 2015 Yann Esposito

View file

@ -1,4 +1,4 @@
(defproject bigbrother "0.1.3-SNAPSHOT"
(defproject bigbrother "0.1.3"
:description "Periodically send metrics"
:url "http://github.com/yogsototh/bigbrother"
:license {:name "MIT"

View file

@ -150,15 +150,27 @@ end
(defn display-time
"display the time at most every 10s"
[nb-ms]
(let [result (resume-map nb-ms)]
(log/info (json/write-str result))
(send-to-riemann result)
(reset-accumulators!)))
(try
(let [result (resume-map nb-ms)]
(log/info (json/write-str result))
(send-to-riemann result)
(reset-accumulators!))
(catch Throwable t
(log/error t)
; (.printStackTrace t)
)))
(defn protected [f]
(try (f)
(catch Throwable t
(log/error t)
; (.printStackTrace t)
(protected f))))
(defn init-metrics
"## init-metrics
init-map :: Map Keyword (v -> ERROR_LEVEL)"
init-map :: Map Keyword (v -> ERROR_LEVEL)"
[init-map nb-ms-metrics riemann-host riemann-service-name riemann-default]
(reset! default-map (reduce into {}
(map (fn [k] {k -1} )
@ -169,4 +181,5 @@ end
(reset! riemann-service riemann-service-name)
(when riemann-host
(reset! riemann-conn (r/tcp-client {:host riemann-host})))
(every nb-ms-metrics (fn [] (display-time nb-ms-metrics)) @pool))
(protected
#(every nb-ms-metrics (fn [] (display-time nb-ms-metrics)) @pool)))