Skip to content

Commit

Permalink
Merge pull request #46 from kailashnath/master
Browse files Browse the repository at this point in the history
`falsy` valued attributes should not be dropped
  • Loading branch information
jamtur01 authored Jan 10, 2020
2 parents c200541 + c4607af commit 32ceda4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/riemann/codec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
(.setTime event (long (:time e)))))
(when (:ttl e) (.setTtl event (:ttl e)))
(doseq [k (clojure.set/difference (set (keys e)) event-keys)]
(when-let [v (get e k)]
(when-some [v (get e k)]
(let [a (Proto$Attribute/newBuilder)]
(.setKey a (str (when (namespace k) (str (namespace k) \/)) (name k)))
(.setValue a (str v))
Expand Down
12 changes: 12 additions & 0 deletions test/riemann/codec_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@
expected (dissoc original :empty-attr)]
(is (= (msg {:events [expected]})
(roundtrip {:events [original]})))))

(deftest false-custom-attributes
(let [original {:host "host.1"
:service "service.1"
:nil-attr nil
:false-attr false}
expected (-> original
(dissoc :nil-attr)
(assoc :false-attr "false"))]
(is (= (msg {:events [expected]})
(roundtrip {:events [original]}))
"false values should be converted to string and not be removed")))

0 comments on commit 32ceda4

Please sign in to comment.