Skip to content

Middlewares for reporting request/response metrics to statsd

Notifications You must be signed in to change notification settings

tbatchelli/ring.middleware.statsd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ring.middleware.statsd

Build Status

Simple ring middlewares for collecting request/response metrics to statsd.

Usage

Current semantic version:

[ring.middleware.statsd "1.0.0"]

API Documentation

Configure statsd server

(ring.middleware.statsd/setup! "statsd.host" 1234)

wrap-timer

Record response times under timer named "resp_time"

(def app
  (wrap-timer handler :resp_time))

wrap-request-method-counter

Record counters for request methods, as "req_method.get", "req_method.post", etc

(def app
  (wrap-request-method-counter handler :req_method))

wrap-response-code-counter

Record counters for response statuses, as "resp_status.200", "resp_status.404", etc

(def app
  (wrap-response-code-counter handler :resp_status))

You can customize the counter or filter which statuses are counted by passing :key-fn argument.

;; count only HTTP OK as "resp_status.ok". All non-200 response not counted.
(def app
  (wrap-response-code-counter
    handler
    :resp_status
    :key-fn #(if (= % 200) "ok")))
;; bucket responses into "resp_status.2XX", "resp_status.4XX", and so on
(def app
  (wrap-response-code-counter
    handler
    :resp_status
    :key-fn #(str (quot % 100) "XX")))

License

Copyright © 2013 Logan Linn

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

About

Middlewares for reporting request/response metrics to statsd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%