This plugin will make New Relic instrumentation available to a Grails project. New Relic provides some extensive documentation on adding their Agent to a running web application, however the Real User Monitoring (RUM) feature is not automatically enabled for GSP pages. This project aims to bridge that gap by providing a taglib to call on the GSP Layout page.
New Relic needs to be installed on the running application server in order for the plugin to work. This is extensively documented by the New Relic team.
Once installed, New Relic will need to be configured to both enable RUM and turn off auto instrumentation.
This plugin is hosted on Grails Plugins Central so it is as easy as:
grails install-plugin newrelic
Once New Relic and this plugin has been added to your web application, you are ready to add the tags to your page(s). New Relic provides some recommendations on when to all these tag methods. Ideally, you would only need to add it to your layout page(s) 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>
However, if there are more GSP that need these tags, then just make sure they are added at the appropriate locations in the DOM.
By default the New Relic RUM code will only be enabled for Production environments. If you need it to be enabled for other environments, make sure that it is explicitly enabled in your configs
newrelic.enabled = true
NewRelic should be enabled in the production environment as per the instructions here, but if you need to enable this in other environments, make sure that the configs have enabled NewRelic for your environment, and add the following to your GRAILS_OPT environment
export GRAILS_OPTS="-javaagent:/path/to/newrelic.jar"
The next time you execute 'run-app' or 'run-war', NewRelic instrumentation code will be included in your generated HTML pages.
On newer versions of grails that use a forked jvm, you may need to include the java agent in your tomcat configuration. This is in BuildConfig.groovy.
grails.tomcat.jvmArgs = ["-javaagent:/path/to/newrelic.jar"]
For other usages of the NewRelic plugin, see the wiki pages for more information.