Skip to content

mhuebner/grails-sentry

 
 

Repository files navigation

Sentry Grails Plugin

Build Status Download

Introduction

Sentry plugin provides a Grails client for integrating apps with Sentry. Sentry is an event logging platform primarily focused on capturing and aggregating exceptions.

It uses the official Raven-java client under the cover.

Installation

Declare the plugin dependency in the build.gradle file, as shown here:

dependencies {
    ...
    compile("org.grails.plugins:sentry:7.8.1")
    ...
}

Config

Add your Sentry DSN to your grails-app/conf/application.yml.

grails:
    plugin:
        sentry:
            dsn: https://{PUBLIC_KEY}:{SECRET_KEY}@app.getsentry.com/{PATH}{PROJECT_ID}

The plugin will sent notifications to Sentry by default, if you want to disable notifications for an specific environment set the active option as false.

environments:
    development:
        grails:
            plugin:
                sentry:
                    active: false
    test:
        grails:
            plugin:
                sentry:
                    active: false

You can also configure the multiple logger to which you want to append the sentry appender. You can also set the server name, but it is recommended to don't set this configuration and let the plugin to resolve it.

Optional configurations

# Not tested on Grails 3 plugin...
grails:
    plugin:
        sentry:
            loggers: [LOGGER1, LOGGER2, LOGGER3]
            environment: staging
            serverName: dev.server.com
            levels: [ERROR]
            tags: {tag1: val1,  tag2: val2, tag3: val3}
            subsystems: 
                MODULE1: [com.company.services.module1, com.company.controllers.module1]
                MODULE2: [com.company.services.module2, com.company.controllers.module2]
                MODULE3: [com.company.services.module3, com.company.controllers.module3]
            logClassName: true
            logHttpRequest: true
            disableMDCInsertingServletFilter: true
            springSecurityUser: true
            springSecurityUserProperties:
                id: 'id'
                email: 'emailAddress'
                username: 'login'
            priorities: 
                HIGH: [java.lang, com.microsoft.sqlserver.jdbc.SQLServerException]
                MID: [com.company.exception]
                LOW: [java.io]

Check Raven-java documentation to configure connection, protocol and async options in your DSN. If you are sending extra tags from the plugin for the exceptions, make sure to enable the corresponding tag on sentry tag settings for the particular project to see the tag as a filter on the exception stream on sentry.

Usage

Logback Appender

The Logback Appender is automatically configured by the plugin, you just have to set enabled environments as shown in Configuration section.

All application exceptions will be logged on sentry by the appender. The appender is configured to log just the ERROR and WARN levels. To log manually just use the log.error() method.

ravenClient

You also can use raven client to sent info messages to Sentry:

import com.getsentry.raven.Raven
import com.getsentry.raven.event.Event
import com.getsentry.raven.event.EventBuilder

Raven raven // To inject Spring bean raven client in your controllers or services

// Send simple message
raven?.sendMessage("some message")

// Send exception
raven?.sendException(new Exception("some exception"))

// Custom event
EventBuilder eventBuilder = new EventBuilder(
        message: "Hello from Raven!",
        level: Event.Level.ERROR,
        logger: TestController.class.name
).addSentryInterface(
        new ExceptionInterface(
                new Exception("some exception")
        )
)
raven?.sendEvent(eventBuilder.build())

Latest releases

  • 2017-02-01 V7.8.1 : upgrade Sentry java lib to 7.8.1
  • 2016-11-22 V7.8.0.2 : event environment support
  • 2016-10-29 V7.8.0.1 : minor bug fix, thanks to donbeave PR
  • 2016-10-19 V7.8.0 : upgrade Sentry java lib to 7.8.0
  • 2016-10-10 V7.7.1 : upgrade Sentry java lib to 7.7.1
  • 2016-09-27 V7.7.0.1 : bug fix
  • 2016-09-26 V7.7.0 : upgrade Sentry java lib to 7.7.0, release support added to events
  • 2016-08-22 V7.6.0 : upgrade Sentry java lib to 7.6.0, Spring Security integration improvements, thanks to donbeave PR
  • 2016-07-22 V7.4.0 : upgrade Sentry java lib to 7.4.0, better logging and support for Spring Security Core , thanks to donbeave PR
  • 2016-06-22 V7.3.0 : upgrade Sentry java lib to 7.3.0
  • 2016-05-03 V7.2.1 : upgrade Sentry java lib to 7.2.1
  • 2016-04-12 V7.1.0.1 : minor update
  • 2016-04-06 V7.1.0 : upgrade Sentry java lib to 7.1.0, thanks to donbeave PR (WARNING: Raven package has been renamed from net.kencochrane.raven to com.getsentry.raven)
  • 2015-08-31 V6.0.0 : initial release for Grails 3.x

Bugs

To report any bug, please use the project Issues section on GitHub.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

License

Copyright © 2016 Alan Rafael Fachini, authors, and contributors. All rights reserved.

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

Maintained by

Agorapulse & Scentbird

About

A Sentry client for Grails

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 97.2%
  • Shell 2.8%