{"id":15591110,"url":"https://github.com/coderberry/airbrake-grails","last_synced_at":"2025-04-24T05:35:02.400Z","repository":{"id":4577772,"uuid":"5719473","full_name":"coderberry/airbrake-grails","owner":"coderberry","description":"Airbrake Client for Grails","archived":false,"fork":false,"pushed_at":"2016-10-23T03:50:43.000Z","size":423,"stargazers_count":4,"open_issues_count":12,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T07:22:54.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderberry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-07T16:37:02.000Z","updated_at":"2014-11-17T22:57:39.000Z","dependencies_parsed_at":"2022-08-24T23:34:23.117Z","dependency_job_id":null,"html_url":"https://github.com/coderberry/airbrake-grails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderberry%2Fairbrake-grails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderberry%2Fairbrake-grails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderberry%2Fairbrake-grails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderberry%2Fairbrake-grails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderberry","download_url":"https://codeload.github.com/coderberry/airbrake-grails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250572661,"owners_count":21452334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T23:40:20.524Z","updated_at":"2025-04-24T05:35:02.383Z","avatar_url":"https://github.com/coderberry.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Airbrake Plugin for Grails\n\nThis is the notifier plugin for integrating grails apps with [Airbrake](http://airbrake.io).\n\nWhen an uncaught exception occurs, Airbrake will POST the relevant data to the Airbrake server specified in your environment.\n\n## Installation \u0026 Configuration\n\nAdd the following to your `BuildConfig.groovy`\n\n```\ncompile \":airbrake:0.9.4\"\n```\n\nOnce the plugin is installed, you need to provide your Api Key in `Config.groovy` file:\n\n```groovy\ngrails.plugins.airbrake.apiKey = 'YOUR_API_KEY'\n```\n\n## Usage\n\nOnce you have installed and configured the plugin there is nothing else to do. Uncaught exceptions will be logged by log4j and those errors will be reported to Airbrake. However, the plugin also exposes a few other ways to send errors to airbrake.\n\n### Logging Errors with Exceptions\n\nManually logging messages at the error level and including an Exception triggers an error notification to airbrake:\n\n```groovy\nclass SomeController\n\tdef someAction() {\n\t\ttry {\n\t\t\tsomethingThatThrowsAnException()\n\t\t} catch(e) {\n\t\t\tlog.error('An error occured', e)\n\t\t}\n\t}\n```\n\n(See the section below on configuring the plugin to including errors without exceptions.)\n\n### AirbakeService\n\nThe plugin also exposes an `airbrakeService` which can be dependency injected into your Grails classes. The service allows you to send error notifications directly to Airbrake without logging anything to log4j. It has a `notify` method that takes a `Throwable` parameter and an optional Map of arguemnts. The next example shows both in use:\n\n```groovy\nclass SomeController\n\tdef airbrakeService\n\t\n\tdef someAction() {\n\t\ttry {\n\t\t\tsomethingThatThrowsAnException()\n\t\t} catch(e) {\n\t\t\tairbrakeService.notify(e, [errorMessage: 'An error occurred'])\n\t\t}\n\t}\n\n\tdef anotherAction() {\n\t\tif (somethingWentWrong()) {\n\t\t\tairbrakeService.notify(null, [errorMessage: 'Something went wrong'])\n\t\t}\n\t}\n```\n\n## Advanced Configuration\nThe Api Key is the minimum requirement to report errors to Airbrake. However, the plugin supports several other configuration options. The full list of configuration options is:\n\n```groovy\ngrails.plugins.airbrake.apiKey\ngrails.plugins.airbrake.enabled\ngrails.plugins.airbrake.env\ngrails.plugins.airbrake.includeEventsWithoutExceptions\ngrails.plugins.airbrake.paramsFilteredKeys\ngrails.plugins.airbrake.sessionFilteredKeys\ngrails.plugins.airbrake.cgiDataFilteredKeys\ngrails.plugins.airbrake.host\ngrails.plugins.airbrake.port\ngrails.plugins.airbrake.secure\ngrails.plugins.airbrake.async\ngrails.plugins.airbrake.asyncThreadPoolSize\ngrails.plugins.airbrake.stackTraceFilterer\ngrails.plugins.airbrake.excludes\n```\n\n### Enabling/Disabling Notifications\nBy default all errors are sent to Airbrake. However, you can disable error notifications (essentially disabling the plugin) by setting `grails.plugins.airbrake.enabled = false`. For example to disable error notificaitons in development and test environments you might have the following in `Config.groovy`:\n\n```groovy\ngrails.plugins.airbrake.apiKey = 'YOUR_API_KEY'\nenvironments {\n\tdevelopment {\n\t\tgrails.plugins.airbrake.enabled = false\n\t}\n\ttest {\n\t\tgrails.plugins.airbrake.enabled = false\n\t}\n```\n\n#### Disabling Notifications by Exception Type\nFor example, to disable notifications caused by `IllegalArgumentException` and `IllegalStateException`, configure\n\n````groovy\ngrails.plugins.airbrake.excludes = ['java.lang.IllegalArgumentException', 'java.lang.IllegalStateException']\n````\n\neach entry in the list will be converted to a `Pattern` and matched against the exception class name, so the following\nwould also exclude these two exceptions:\n\n````groovy\ngrails.plugins.airbrake.excludes = ['java.lang.Illegal.*Exception']\n````\n\n#### Runtime Enabling/Disabling\nIf you wish to enable/disable notifications at runtime you have a couple of options\n\n* Call the service method `airbrakeService.setEnabled(boolean enabled)`\n* Invoke the `setEnabled` action of `AirbrakeTestController`. This action expects a single parameter either `enabled=true` or `enabled=false`\n\n\n### Setting the Environment\nBy default, the environment name used in Airbrake will match that of the current Grails environment. To change this default, set the env property:\n\n```groovy\ngrails.plugins.airbrake.env = grails.util.Environment.current.name[0..0] // Airbrake env name changed from default value of Development/Test/Production to D/T/P\n```\n\n### Including all events logged at the Error level\n\nBy default only uncaught errors or errors logged with an exception are reported to Airbrake. It is often convenient to loosen that restriction so that all messages logged at the `Error` level are reported to Airbrake. This often most useful in `src/java` or `src/groovy` classes that can more easily have a log4j logger than get accees to the dependency injected `airbrakeService`. \n\nWith the following line in `Config.groovy`:\n\n```groovy\ngrails.plugins.airbrake.includeEventsWithoutExceptions = true\n```\n\nthen logged errors get reported to Airbrake:\n\n```groovy\n@Log4j\nclass SomeGroovyClass {\n\tdef doSomething() {\n\t\tif (somethingWentWrong()) {\n\t\t\tlog.error('Something went wrong')\n\t\t}\n\t}\n}\n```\n\nNote: It might be reasonable to have this setting true by default but for backwards compatibility with previous versions of te plugin the default is false.\n\n### Filtering Parameters sent to Airbrake\nTo prevent certain parameters from being sent to Airbrake you can configure a list of parameter names to filter out. The configuration settings `paramsFilteredKeys`, `sessionFilteredKeys` and `cgiFilteredKeys` filter the params, session and cgi data sent to Airbrake.\nFor example to prevent any web request parameter named 'password' from being included in the notification to Airbrake you would use the following configuration:\n```groovy\ngrails.plugins.airbrake.paramsFilteredKeys = ['password']\n```\n\nEach configuration option also supports regular expression matching on the keys. For example the following configuration would prevent all session data from being sent to Airbrake:\n```groovy\ngrails.plugins.airbrake.sessionFilteredKeys = ['.*']\n```\n\n\n### Custom Airbrake Host, Port and Scheme\n\nIf you are running the Airbrake server locally (or a clone thereof, e.g. Errbit), you will need to customise the server URL, port, scheme, etc.\nFor example to change the server host and port, add the following configuration parameters:\n\n````groovy\ngrails.plugins.airbrake.host = 'errbit.example.org'\ngrails.plugins.airbrake.port = 8080\n````\n\n### Adding Custom Data to Error Notifications\n\n### Supplying User Data\n\nAirbrake allows certain User data to be supplied with the notice. To set the current users data to be included in all notifications use the `airbrakeService.addNoticeContext` method to set a map of userData.\nThe supported keys are `id`, `name`, `email` and `username`\n```groovy\nairbrakeService.addNoticeContext(id: '1234', name: 'Bugs Bunny', email: 'bugs@acme.com', username: 'bugs')\n```\n\nIn most web apps the simplest way to provide this context is in a Grails filter. For example if you are using `SpringSecurity` add the following `AirbrakeFilter.groovy` in `grails-app/conf`\n```groovy\nclass AirbrakeFilters {\n    def airbrakeService\n    def springSecurityService\n\n    def filters = {\n        all(uri: '/**') {\n            before = {\n                def user = springSecurityService.currentUser\n                if (user) {\n                   airbrakeService.addNoticeContext(user: [id: user.id, name: user.name, email: user.email, username: user.username ])\n                }\n            }\n        }\n    }\n}\n```\n\n## Synchronous/Asynchronous notifications\n\nBy default, notifications are sent to Airbrake asynchronously using a thread-pool of size 5. To change the size of this thread\npool set the following config parameter:\n\n```groovy\n// double the size of the pool\ngrails.plugins.airbrake.asyncThreadPoolSize = 10\n```\n\nTo have the notifications sent synchronously, set the async parameter to false:\n\n```groovy\n// send notifications synchronously\ngrails.plugins.airbrake.async = false\n```\n\n### Custom Asynchronous Handler\nTo send the notifications asynchronously using a custom handler, use the async configuration option.\nThis configuration takes a closure with two parameters the `Notice` to send and the `grailsApplication`. The asynchronous handler should simply call `airbrakeService.sendNotice(notice)` to deliver the notification.\n\nThis plugin does not introduce a default choice for processing notices asynchronously. You should choose a method that suits your application.\nYou could just create a new thread or use a scheduler/queuing plugin such as [Quartz](http://grails.org/plugin/quartz) or [Jesque](http://grails.org/plugin/jesque)\n\nFor example if you are using the Quartz plugin you can send notifications asynchronously using the following setting in `Config.groovy`\n\n```groovy\ngrails.plugins.airbrake.async = { notice, grailsApplication -\u003e\n    AirbrakeNotifyJob.triggerNow(notice: notice)\n}\n```\n\nand the `AirbrakeNotifyJob` is defined in `grails-app\\jobs` something like this:\n\n```groovy\nclass AirbrakeNotifyJob {\n    def airbrakeService\n\n    def execute(JobExecutionContext context) {\n        Notice notice = context.mergedJobDataMap.notice\n        if (notice) {\n            airbrakeService.sendNotice(notice)\n        }\n    }\n}\n```\n\n### Stack Trace Filtering\nBy default all stack traces are filtered using an instance of `org.codehaus.groovy.grails.exceptions.DefaultStackTraceFilterer` to remove common Grails and java packages.\nTo provide custom stack trace filtering simple configure an instance of a class that implements the interface `org.codehaus.groovy.grails.exceptions.StackTraceFilterer` in `Config.groovy`\n\n```groovy\ngrails.plugins.airbrake.stackTraceFilterer = new MyCustomStackTraceFilterer()\n```\n\n## Compatibility\n\nThis plugin is compatible with Grails version 2.0 or greater. A backport to Grails 1.3 is available on the [grails-1.3 branch] (https://github.com/cavneb/airbrake-grails/tree/grails-1.3).\n\n## Release Notes\n\n* 0.7 - 2012/09/21\n\t* Added support for filtering parameters, session and cgiData. #2\n* 0.7.1 - 2012/09/21\n\t* Change supported Grails version to 2.0.0. #3\n* 0.7.2 - 2012/09/24\n\t* Added User Agent, Hostname and user data to notifications\n* 0.8 - 2012/10/16\n\t* Simpler configuration (Breaking change)\n\t* Default notification environment to current Grails environment. #9\n\t* Support for notifying caught exceptions. #15\n\t* Support for notifying all messages logged at the error level (with or without exceptions)\n\t* Simpler api for providing user data\n\t* Full class names in stacktrace. #11\n* 0.8.1 - 2012/10/19\n\t* Better error message for uncaught exceptions. #18\n* 0.9.0 - 2012/10/29\n    * Support for sending notifications to Airbrake asynchronously\n    * Added method to AirbrakeService set notification context information that will be used for any reported errors\n    * Simpler api to provide User Data. No need to implement UserDataService instead just set the context. (Breaking Change)\n    * All request headers now included when reporting an error.\n* 0.9.1 - 2012/11/30\n    * Notifications sent to Airbrake asynchronously by default using a thread pool of configurable size #20\n    * By default stack traces are filtered #19\n    * New configuration option to support custom stack trace filtering\n    * New configuration options for filtering params, session and cgi data independently\n* 0.9.2 - 2013/1/19\n    * Support for Grails 2.2 and Groovy 2.0 #27\n* 0.9.3 - 2013/05/10\n    * New feature to enable/disable notification send while the plugin is running #31\n    * New configuration option to filter exceptions by name or pattern #34\n    * Bug fix. Don't send notifications synchronously by default #26\n    * Bug fix. Handle empty backtrace more gracefully for Errbit #33\n    * Thanks to @domurtag for all the fixes\n* 0.9.4 - 2013/06/25\n    * Bug fix. AirbrakeNotifier.notify no longer throws under any circumstance.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n# Kudos\n\nThe origin version of this plugin was written by Phuong LeCong ([https://github.com/plecong/grails-airbrake](https://github.com/plecong/grails-airbrake)).\nSince then it has undergone significant refactoring and updates inspired by the Ruby Airbrake gem ([https://github.com/airbrake/airbrake](https://github.com/airbrake/airbrake))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderberry%2Fairbrake-grails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderberry%2Fairbrake-grails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderberry%2Fairbrake-grails/lists"}