Skip to content

Commit

Permalink
Merge branch 'master' of github.com:aphyr/riemann
Browse files Browse the repository at this point in the history
  • Loading branch information
aphyr committed Jun 1, 2015
2 parents ef81985 + 1537a2b commit 3534463
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/riemann/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@
(seq [this]
(seq source))

Instrumented
(instrumentation/events [this]
(instrumentation/events source))

ServiceEquiv
(equiv? [this other]
(and (satisfies? WrappedIndex other)
Expand Down
10 changes: 9 additions & 1 deletion src/riemann/index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
Index: indexing and querying events
Seqable: returning a list of events
Service: lifecycle management"
(:require [riemann.query :as query])
(:require [riemann.query :as query]
[riemann.instrumentation :refer [Instrumented]])
(:use [riemann.time :only [unix-time]]
riemann.service)
(:import (org.cliffc.high_scale_lib NonBlockingHashMap)))
Expand Down Expand Up @@ -93,6 +94,13 @@
(lookup [this host service]
(.get hm [host service]))

Instrumented
(events [this]
(let [base {:state "ok" :time (unix-time)}]
(map (partial merge base)
[{:service "riemann index size"
:metric (.size hm)}])))

clojure.lang.Seqable
(seq [this]
(seq (.values hm)))
Expand Down
8 changes: 8 additions & 0 deletions test/riemann/index_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:use riemann.index
riemann.core
riemann.query
[riemann.instrumentation :only [events]]
[riemann.common :only [event]]
[riemann.time :only [unix-time]]
clojure.test)
Expand Down Expand Up @@ -71,6 +72,13 @@
(is (= 5 (:metric (lookup i 1 1))))
(is (= 7 (:metric (lookup i 1 2))))))

(deftest nbhm-instrumentation
(let [i (wrap-index (index))]

(i {:host 1 :service 1 :metric 5 :time 0})
(i {:host 1 :service 2 :metric 7 :time 0})

(is (= 2 (:metric (first (filter #(= (:service %) "riemann index size") (events i))))))))

(defn random-event
[& {:as event}]
Expand Down

0 comments on commit 3534463

Please sign in to comment.