/dropwizard-sentry

Dropwizard integration for error logging to Sentry.

Primary LanguageJavaApache License 2.0Apache-2.0

Dropwizard Sentry

Build Status Maven Central Javadocs

Dropwizard integration for error logging to Sentry. This is a simpler version where you don't need to configure DSN and other options on the application's YAML. Useful when using other logging libs besides Logback (Dropwizard's logging backend). Forked from dhatim's dropwizard-sentry.

Usage

Dropwizard Sentry 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 SentryAppenderFactory has been properly initialized), the Dropwizard application has to run the SentryBootstrap.bootstrap() in its main method and set a custom UncaughtExceptionHandler for the main thread.

public static void main(String[] args) throws Exception {
    SentryBootstrap.bootstrap();
    Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());

    new MyDropwizardApplication().run(args);
}

Configuration

Include the sentry appender in your application's YAML configuration:

appenders:
  - type: sentry
    threshold: ERROR
Setting Default Description Example Value
threshold ALL The log level to configure to send to Sentry ERROR

Other options, like DSN and Sample Rate, should be configured as described on Sentry documentation.

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>io.github.knonm</groupId>
  <artifactId>dropwizard-sentry</artifactId>
  <version>2.1.8</version>
</dependency>

Support

Please file bug reports and feature requests in GitHub issues.