Skip to content

Commit

Permalink
Cast the time in long on the pagerduty stream.
Browse files Browse the repository at this point in the history
Riemann event `:time` can be a double (for example,
`(riemann.time/unix-time)` returns a double), and so produces an
exception in the pagerduty v2 steam (in the `(coerce/from-long)` function).
  • Loading branch information
mcorbin authored and jamtur01 committed Jun 21, 2018
1 parent 7dd904b commit 8128171
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/riemann/pagerduty.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
(:metric event) ")")
:source (:host event)
:severity (:state event)
:timestamp (->> (or (:time event) (long (riemann.time/unix-time)))
:timestamp (->> (long (or (:time event) (long (riemann.time/unix-time))))
(coerce/from-long)
(f/unparse timestamp-formatter))
:custom_details event})
Expand Down
9 changes: 8 additions & 1 deletion test/riemann/pagerduty_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@
:timestamp "1970-01-01T00:00:00.000Z"
:custom_details event
:severity "critical"}
(pg/format-event-v2 event))))))
(pg/format-event-v2 event))))
(testing "with time in double"
(is (= {:summary "riemann.io - req_per_sec is critical (100)"
:source "riemann.io"
:timestamp "1970-01-01T00:00:00.100Z"
:custom_details (assoc event :time 100.111)
:severity "critical"}
(pg/format-event-v2 (assoc event :time 100.111)))))))

(deftest request-body-v1-test
(let [service-key "fookey"
Expand Down

0 comments on commit 8128171

Please sign in to comment.