Dropwizard integration for error logging to Sentry.
The Dropwizard Raven provides an AppenderFactory
which is automatically registered in Dropwizard and will send errors to Sentry.
In order to log startup errors (i.e. before the RavenAppenderFactory
has been properly initialized), the Dropwizard application has to run the RavenBootstrap.bootstrap()
in its main
method and set a custom UncaughtExceptionHandler
for the main thread.
public static void main(String[] args) throws Exception {
RavenBootstrap.bootstrap(DSN);
Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());
new MyDropwizardApplication().run(args);
}
The Logback SentryAppender
can be configured using the provided RavenConfiguration
class which basically mirrors the appender configuration outlined in raven-logback.
Include the raven
appender in your config.yml
:
appenders:
- type: console
- type: raven
dsn: https://user:pass@getsentry.com/appid
environment: production
extraTags: foo,bar,baz
ravenFactory: com.example.RavenFactory
release: 1.0.0
serverName: 10.0.0.1
tags: tag:value,tag2:value
Setting | Default | Description | Example Value |
---|---|---|---|
dsn |
Data Source Name - 'https://{PUBLIC_KEY}:{SECRET_KEY}@sentry.io/{PROJECT_ID}' |
https://foo:bar@sentry.io/12345 |
|
environment |
[empty] | The environment your application is running in | production |
extraTags |
[empty] | Additional tag names to be extracted from MDC when using SLF4J |
foo,bar,baz |
ravenFactory |
[empty] | Specify a custom RavenFactory class |
com.example.RavenFactory |
release |
[empty] | The release version of your application | 1.0.0 |
serverName |
[empty] | Override the server name (rather than looking it up dynamically) | 10.0.0.1 |
tags |
[empty] | Additional tags to be sent with errors | tag1:value1,tag2:value2 |
This project is available in the Central Repository. To add it to your project simply add the following dependency to your POM:
<dependency>
<groupId>com.tradier</groupId>
<artifactId>dropwizard-raven</artifactId>
<version>1.0.0-1</version>
</dependency>
Please file bug reports and feature requests in GitHub issues.
Thanks to gini for dropwizard-gelf from which much of the original implementation was derived.
Copyright (c) 2014-2016 Tradier Inc. See LICENSE for detail.