Home

Awesome

Dropwizard Raven

Maven Central Build Status

Dropwizard integration for error logging to Sentry.

Usage

The Dropwizard Raven provides an AppenderFactory which is automatically registered in Dropwizard and will send errors to Sentry.

Logging startup errors

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

Configuration

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: raven
    threshold: ERROR
    dsn: https://user:pass@sentry.io/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

Configuration Settings

SettingDefaultDescriptionExample Value
thresholdALLThe log level to configure to send to SentryERROR
dsnData 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 inproduction
extraTags[empty]Additional tag names to be extracted from MDC when using SLF4Jfoo,bar,baz
ravenFactory[empty]Specify a custom RavenFactory classcom.example.RavenFactory
release[empty]The release version of your application1.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 errorstag1:value1,tag2:value2

Maven Artifacts

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>

Support

Please file bug reports and feature requests in GitHub issues.

Acknowledgements

Thanks to gini for dropwizard-gelf from which much of the original implementation was derived.

Copyright

Copyright (c) 2014-2016 Tradier Inc. See LICENSE for detail.