Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Clojure client for the Airbrake API

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 src Stopped santizing urls as they don't need to be April 03, 2014
Octocat-spinner-32 test-resources
Octocat-spinner-32 test Include the querystring in the url when submitting messages to airbrake April 02, 2014
Octocat-spinner-32 .gitignore update to lein 2. add target to gitignore August 20, 2013
Octocat-spinner-32 releases v2.4.2 April 16, 2014
Octocat-spinner-32 project.clj releases v2.4.2 April 16, 2014


Clojure client for the Airbrake API


(require '[clj-airbrake.core :as airbrake])

(def request {:url "" :component "foo" :action "bar"
             :cgi-data {"SERVER_NAME" "nginx", "HTTP_USER_AGENT" "Mozilla"}
             :params {"city" "LA", "state" "CA"}
             :session {"user-id" "23"}})

(def exception (try (throw (Exception. "Foo")) (catch Exception e e)) ; throw to get a stacktrace

;; send in blocking style using the JDK's http libs
(airbrake/notify "my-api-key" "production" "/app/dir" exception request)
=> {:error-id 42 :id 100 :url ""}

;; send async using http-kit and callbacks
(airbrake/notify-async (fn [resp] ...) "my-api-key" "production" "/app/dir" exception request)

;; the notify and notify-async fns are also dynamic vars if you wish to swap them out for
;; a different implementation using the same XML request helpers in clj-airbrake.core

Note that the request is one-to-one with Airbrake's API and not a Ring request. If you are using ring please see below about the provided ring middleware.

The request is optional but is the only way the Airbrake API allows you to pass in additonal information. So, if you are using the client out of the context of a web application you can use the request to send in enviromental variables or anything else that may help in troubleshooting. Note, that url in the request is required if you do provide a request hashmap.

Additional Configuration

If you need to change the host name where the errors are sent you you can use the #'set-host! function:

(require '[clj-airbrake.core :as airbrake])

(airbrake/set-host! "")


clj-airbrake is available as a Maven artifact Clojars.


  [[clj-airbrake "2.4.2"] ...]




Running the tests:

$ lein deps
$ lein test

Ring Middleware

Basic support for Ring is provided in the clj-airbrake.ring namespace: request parameters and session information are passed to Airbrake. A simple ring example:

(use 'ring.adapter.jetty)
(use 'ring.middleware.params)
(use 'ring.middleware.stacktrace)
(use 'clj-airbrake.ring)

(defn app [req]
  {:status  200
   :headers {"Content-Type" "text/html"}
   :body    (throw (Exception. "Testing"))})

(run-jetty (-> app
               (wrap-airbrake "MY-API-KEY")
           {:port 8080})


  • Param filtering. (e.g. automatically filter out any 'password' params)
  • Allow for certain environments to be ignored... defaulting to #{"test" "development"}
  • Configuartion management? i.e. set api-key once


Copyright (C) 2010 LeadTune and Ben Mabey

Released under the MIT License:

Something went wrong with that request. Please try again.