Created
May 4, 2016 14:06
-
-
Save agile/a71aa57fa7dd4dbb47854fcd88026696 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -*- mode: clojure; -*- | |
; vim: filetype=clojure | |
(logging/init) | |
(repl-server {:host "127.0.0.1" :port 55554}) | |
(let [host "0.0.0.0"] | |
(tcp-server {:host host :port 55555}) | |
(udp-server {:host host :port 55555}) | |
(ws-server {:host host :port 55556}) | |
) | |
(periodically-expire 30) | |
(let [index (tap :index (index)) | |
graph (sdo | |
#(info "graphing: " %) | |
; stub-service for graphite that just writes what it gets to a log | |
(graphite {:host "192.168.199.12"})) ] | |
(streams | |
(where (not= "expired" (:state event)) | |
(split | |
(tagged-any ["derive"] | |
(sdo | |
index | |
(by [:host :service] | |
(adjust [:service str "_rate"] | |
(ddt index graph))))))))) | |
(tests | |
(deftest how-ddt-works-as-child-of-by | |
(let [tap (inject! [ | |
; metric suite 1 | |
{:host "host-a" :service "a_service" :metric 100 :time 10 :tags ["derive"]} | |
{:host "host-b" :service "a_service" :metric 100 :time 10 :tags ["derive"]} | |
{:host "host-c" :service "a_service" :metric 100 :time 10 :tags ["derive"]} | |
; metric suite 2 | |
{:host "host-a" :service "a_service" :metric 150 :time 20 :tags ["derive"]} | |
{:host "host-b" :service "a_service" :metric 150 :time 20 :tags ["derive"]} | |
{:host "host-c" :service "a_service" :metric 150 :time 20 :tags ["derive"]} ]) | |
index (:index tap) ] | |
; this stub graphite service confirms same results | |
; 1462370588.79526: host-a.a_service_rate 5 20 | |
; 1462370588.79600: host-b.a_service_rate 5 20 | |
; 1462370588.79636: host-c.a_service_rate 5 20 | |
(let [event (lookup index "host-a" "a_service_rate")] | |
(is (= (:metric event) (/ (- 150 100) 10)))) | |
(let [event (lookup index "host-b" "a_service_rate")] | |
(is (= (:metric event) (/ (- 150 100) 10)))) | |
(let [event (lookup index "host-c" "a_service_rate")] | |
(is (= (:metric event) (/ (- 150 100) 10))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment