Skip to content

tradier/dropwizard-raven

Repository files navigation

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:[email protected]/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

Setting Default Description Example Value
threshold ALL The log level to configure to send to Sentry ERROR
dsn Data Source Name - 'https://{PUBLIC_KEY}:{SECRET_KEY}@sentry.io/{PROJECT_ID}' https://foo:[email protected]/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

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.