Add to project.clj:
[cognician/dogstatsd-clj "0.1.1"]
Require it:
(require '[cognician.dogstatsd :as d])
To configure, provide URL of DogStatsD:
(d/configure! "localhost:8125")
Optionally, you can provide set of global tags to be appended to every metric:
(d/configure! "localhost:8125" { :tags {:env "production", :project "Secret"} })
After that, you can start reporting metrics:
Total value/rate:
(d/increment! "chat.request.count" 1)
In-the-moment value:
(d/gauge! "chat.ws.connections" 17)
Values distribution (mean, avg, max, percentiles):
(d/histogram! "chat.request.time" 188.17)
To measure function execution time, use d/measure!
:
(d/measure! "thread.sleep.time" {}
(Thread/sleep 1000))
Counting unique values:
(d/set! "chat.user.email" "nikita@mailforspam.com")
Additional options can be specified as third argument to report functions:
{ :tags => [String+] | { Keyword -> Any | Nil }
:sample-rate => Double[0..1] }
Tags can be specified as map:
{:tags { :env "production", :chat nil }} ;; => |#env:production,chat
or as a vector:
{:tags [ "env:production", "chat" ]} ;; => |#env:production,chat
(d/event! "title" "text" opts)
where opts could contain any subset of:
{ :tags => [String+] | { Keyword -> Any | Nil }
:date-happened => java.util.Date
:hostname => String
:aggregation-key => String
:priority => :normal | :low
:source-type=name => String
:alert-type => :error | :warning | :info | :success }
(require '[cognician/dogstatsd :as d])
(d/configure! "localhost:8125" {:tags {:env "production"}})
(d/increment! "request.count" 1 {:tags ["endpoint:messages__list"]
:sample-rate 0.5})
0.1.2
- Remove reflection warnings
0.1.1
- Metric reporting methods now catch all errors, print them to stderr and continue
0.1.0
- Initial release
Copyright © 2015 Cognician Software (Pty) Ltd
Distributed under the Eclipse Public License, the same as Clojure.