Home

Awesome

<p align="center"> <a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank"> <picture> <source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-white.png" media="(prefers-color-scheme: dark)" /> <source srcset="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" /> <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" alt="Sentry" width="280"> </picture> </a> </p>

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us <kbd>Check out our open positions</kbd>

Sentry SDK for Clojure

Clojars Project

A very thin wrapper around the official Java library for Sentry.

This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavour to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.

Usage

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

; You can initialize Sentry manually by providing a DSN or use one of the
; other optional configuration options supplied as a map (see below).

(sentry/init! "https://public:private@sentry.io/1")

; Sending a simple message is easy...

(try
  (do-something-risky)
  (catch Exception e
    (sentry/send-event {:message "Something has gone wrong!"
                        :throwable e})))

If you want an interpolated message, you need to provide the full map, i.e.,

(try
  (do-something-risky)
  (catch Exception e
    (sentry/send-event {:message {:message "Something %s has gone %s!"
                                  :params ["foo" "bar"]}
                        :throwable e})))

Additional Initialisation Options

keydescriptiondefault
:enable-external-configurationEnable loading configuration from the properties file, system properties or environment variables
:environmentSet the environment on which Sentry events will be logged, e.g., "production"production
:debugEnable SDK logging at the debug levelfalse
:releaseAll events are assigned to a particular release
:distSet the application distribution that will be sent with each event
:server-nameSet the server name that will be sent with each event
:shutdown-timeout-millisWait up to X milliseconds before shutdown if there are events to send2000ms
:in-app-includesA seqable collection (vector for example) containing package names to include when sending events
:in-app-excludesA seqable collection (vector for example) containing package names to ignore when sending events
:ignored-exceptions-for-typeSet exceptions that will be filtered out before sending to Sentry (a set of Classnames as Strings)
:enable-uncaught-exception-handlerEnables the uncaught exception handlertrue
:before-send-fnA function (taking an event and a hint)
The body of the function must not be lazy (i.e., don't use filter on its own!) and must return an event or nil
If a nil is returned, the event will not be sent to Sentry
More Information
:before-breadcrumb-fnA function (taking a breadcrumb and a hint)
The body of the function must not be lazy (i.e., don't use filter on its own!) and must return a breadcrumb or nil
If a nil is returned, the breadcrumb will not be sent to Sentry
More Information
:contextsA map of key/value pairs to attach to every Event that is sent.
More Information
:traces-sample-rateSet a uniform sample rate(a number of between 0.0 and 1.0) for all transactions for tracing
:traces-sample-fnA function (taking a custom sample context and a transaction context) enables you to control trace transactions
:serialization-max-depthSet to a lower number, i.e., 2, if you experience circular reference errors when sending events5
:trace-options-requestsSet to enable or disable tracing of options requests.true
:instrumenterSets instrumenter for tracing. (values - :sentry - for default Sentry instrumentation, :otel - OpenTelemetry instrumentation):sentry
:event-processorsA seqable collection (vector for example) containing instances of event processors (implementing io.sentry.EventProcessor)

Some examples:

Basic Initialisation (using defaults):

(sentry/init! "https://public:private@sentry.io/1")

Initialisation with additional options:

(sentry/init! "https://public:private@sentry.io/1" {:environment "staging" :debug true :release "foo.bar@1.0.0" :in-app-excludes ["foo.bar"])
(sentry/init! "https://public:private@sentry.io/1" {:before-send-fn (fn [event _] (when-not (= (.. event getMessage getMessage "foo")) event))})
(sentry/init! "https://public:private@sentry.io/1" {:before-send-fn (fn [event _] (.setServerName event "fred") event)})
(sentry/init! "https://public:private@sentry.io/1" {:contexts {:foo "bar" :baz "wibble"}})

Supported event keys

API Documentation

Breadcrumbs

API Documentation

When an event has a :breadcrumbs key, each element of the value collection should be a map. Each key is optional.

Message

API Documentation

When an event has a :message key, either a simple string can be used, or if you require a parameterised message, the following data should be contained within a map, thus:

User

API Documentation

When an event has a :user key, the data following should be contained within a map. You should provide at either the id or the ip-address.

Request

API Documentation

When an event has a :request key, the data should be contained within a map. Each key is optional.

License

Copyright © 2022 Coda Hale, Sentry

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.