Git Product home page Git Product logo

dropwizard-sentry's Introduction

Dropwizard Sentry

Build Status Maven Central Javadocs

Dropwizard integration for error logging to 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(DSN);
    Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit());

    new MyDropwizardApplication().run(args);
}

Please note that by default startup logger will catch all logs, you can specify custom threshold as following:

public static void main(String[] args) throws Exception {
    SentryBootstrap.Builder()
        .withDsn(DSN)
        .withThreshold(THRESHOLD)
        .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
    dsn: https://user:[email protected]/appid
    environment: production
    release: 1.0.0
    serverName: 10.0.0.1
    inAppIncludes: ['com.example','com.foo']
Setting Default Description Example Value
threshold ALL The minimum log level to send events to Sentry ERROR
dsn Data Source Name - format is https://{PUBLIC_KEY}:{SECRET_KEY}@sentry.io/{PROJECT_ID} https://foo:[email protected]/12345
environment [empty] The environment your application is running in production
tags [empty] Tags to be sent with each event tag1:value1,tag2,value2
configurator [empty] Specify a custom SentryConfigurator class com.example.MySentryConfigurator
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
inAppIncludes [empty] List of package prefixes used by application code ['com.example','com.foo']
inAppExcludes [empty] List of package prefixes not used by application code ['com.thirdparty','com.anotherthirdparty']
contextTags [empty] context tags names applied as Sentry tags to each event ['contextTag1','contextTag2']

If you need to set configuration properties not listed above, append them to the dsn as described here.

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>org.dhatim</groupId>
  <artifactId>dropwizard-sentry</artifactId>
  <version>4.0.5</version>
</dependency>

Support

Please file bug reports and feature requests in GitHub issues.

Acknowledgements

Thanks to dropwizard-raven from which much of the original implementation was derived.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.