Skip to content

devn/dogstatsd-clj

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clojure client for DogStatsD, Datadog’s StatsD agent

Setting things up

Add to project.clj:

[cognician/dogstatsd-clj "0.1.1"]

Require it:

(require '[cognician.dogstatsd :as d])

Configuring

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"} })

Reporting

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")

Tags and throttling

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

Events:

(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 }

Example

(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})

CHANGES

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

License

Copyright © 2015 Cognician Software (Pty) Ltd

Distributed under the Eclipse Public License, the same as Clojure.

About

Clojure client for Datadog's agent statsd service

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Clojure 100.0%