Newrelic Plugin
Dependency :
compile ":newrelic:1.0-2.18.0"
Summary
Newrelic plugin for Grails
Installation
grails install-plugin newrelic
Description
More in-depth documentation is available on the Github page
New Relic
For the plugin to work, NewRelic must be installed and configuredThe Plugin
This plugin allows you to add the Real User Monitoring feature to your GSP pages. By default this plugin is only enabled for Production environments. If you need to enable it for other environments see the configuration section below.Usage in GSP
Once this is complete, the Real User Monitoring code can be added to your GSP page as follows:<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<newrelic:browserTimingHeader/>
<!-- other tags -->
</head>
<body>
<!-- more tags -->
<newrelic:browserTimingFooter/>
</body>
</html>Usage in Controllers/Services
The NewRelic API is accessible through the NewRelic service. This service can be injected into a controller by declaring a bean named newRelicService. The following example code below describes an example situation where the current transaction name and URL is to be logged into NewRelic.package my.blogclass BlogController { def newRelicService def index() { newRelicService.setTransactionName(null, "/blog/view") } }
Configuration
The RUM code will only be added in Production environments. To enable it for other environments add the following configuration to your specific environment confignewrelic.enabled = trueChangelog
- 0.1 - newrelic taglib to allwo RUM from GSP pages.
- 0.2 - NewRelic service can now be injected as a bean. This allows NewRelic Agent APIs to be called from controllers/services.
- 0.3 - Fixed defect where the service is transactional (so always depends on transactionManager bean, and cannot be used in non-transactional services)
- 0.4 - Includes a Filter to automatically name transactions based on controller name, and if specified the action name.
- 0.5 - The Filter now intercepts all URIs, and uses the Request.ServletPath if no controller name is found.
- 0.6 - Updated to use v2.12.0 of the NewRelic API JAR. Removed NewRelic JAR from plugin, it is now downloaded from (public) maven repository.