Last active
January 1, 2016 14:39
-
-
Save espeed/8159198 to your computer and use it in GitHub Desktop.
Here's what you need to do to get the New Relic plugin working with a Clojure/Pedestal app on Heroku.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to configure a Clojure/Herokup app to use the New Relic add-on | |
# for monitoring and to prevent the app from sleeping. | |
# | |
# by James Thornton, http://jamesthornton.com | |
# | |
# Here's what you need to do to get the New Relic plugin working with a | |
# Clojure/Pedestal app on Heroku. | |
# It took some fiddling because there are several versions of docs | |
# floating around for setting up New Relic on a Clojure/Heroku dyno, | |
# but none of them were quite right. | |
# | |
# See https://devcenter.heroku.com/articles/newrelic#clojure-configuration | |
# One of the docs said to add the newrelic.jar to the lib dir, but | |
# don't do that because it will blow up the size of your repo. | |
# First add the New Relic add on via the heroku command line client... | |
$ heroku addons:add newrelic:stark | |
# Your heroku config env vars when you added the New Relic plugin.... | |
$ heroku config | |
=== myapp Config Vars | |
JVM_OPTS: -Xmx400m | |
LEIN_NO_DEV: true | |
NEW_RELIC_LICENSE_KEY: XXXXXXXXXXXXX | |
NEW_RELIC_LOG: stdout | |
PATH: .lein/bin:/usr/local/bin:/usr/bin:/bin | |
# Make sure newrelic.yaml is in the root directory, and update it to include the value of your license_key... | |
# (see https://docs.newrelic.com/docs/java/java-agent-config-file-template) | |
$ grep key newrelic.yml | |
# You must specify the license key associated with your New Relic | |
# account. This key binds your Agent's data to your account in the | |
license_key: 'XXXXXXXXXXXXX' | |
# Make sure you're using at least version 3.2.0 of the newrelic-agent; there was a bug in version 3.1.1. | |
# Here's the relevant bits from my project.clj... | |
:dependencies [ | |
[environ "0.4.0"] | |
[com.newrelic.agent.java/newrelic-agent "3.2.0"]] | |
:java-agents [[com.newrelic.agent.java/newrelic-agent "3.2.0"]] | |
# My Procfile looks like this... | |
$ cat Procfile | |
web: lein with-profile production trampoline run -m myapp.server | |
# Add a system.properties file to root to force Java 7... | |
$ cat system.properties | |
java.runtime.version=1.7 | |
# Add logs to .gitignore so you don't balloon your repo with local logs from running foreman... | |
$ cat .gitignore | |
pom.xml | |
*jar | |
/classes/ | |
/.lein-deps-sum | |
/.lein-failures | |
/.lein-env | |
/checkouts | |
/target | |
/logs | |
# Then just add, commit, and push the config... | |
$ git add . | |
$ git commit -m "adds newrelic add on" | |
$ git push heroku master | |
# Check your logs as it starts to make sure it everything loads properly and doesn't timeout... | |
$ heroku logs -n 1000 | |
2013-12-28T12:10:45.390680+00:00 heroku[web.1]: Starting process with command `lein with-profile production trampoline run -m myapp.server` | |
2013-12-28T12:10:47.315287+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true | |
2013-12-28T12:10:51.658682+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true | |
2013-12-28T12:10:52.250163+00:00 app[web.1]: Dec 28, 2013 12:10:52 +0000 NewRelic 1 INFO: Agent is using Logback | |
2013-12-28T12:10:52.503763+00:00 app[web.1]: Dec 28, 2013 12:10:52 +0000 NewRelic 1 INFO: Loading configuration file "newrelic.yml" | |
2013-12-28T12:10:53.095054+00:00 app[web.1]: Dec 28, 2013 12:10:53 +0000 NewRelic 1 INFO: Agent Host: 2c9a2 IP: 172.3.2.1 | |
2013-12-28T12:10:53.597819+00:00 heroku[web.1]: source=web.1 dyno=heroku.1962 | |
2013-12-28T12:10:57.328065+00:00 app[web.1]: Dec 28, 2013 12:10:57 +0000 NewRelic 1 ERROR: javax/servlet/ServletOutputStream is marked as a weaved class, but no methods are matched to be weaved. | |
2013-12-28T12:10:57.329797+00:00 app[web.1]: Dec 28, 2013 12:10:57 +0000 NewRelic 1 ERROR: javax/servlet/ServletInputStream is marked as a weaved class, but no methods are matched to be weaved. | |
2013-12-28T12:11:07.053518+00:00 app[web.1]: Dec 28, 2013 12:11:06 +0000 NewRelic 1 INFO: Configured to connect to New Relic at collector.newrelic.com:443 | |
2013-12-28T12:11:07.053518+00:00 app[web.1]: Dec 28, 2013 12:11:06 +0000 NewRelic 1 INFO: Setting audit_mode to false | |
2013-12-28T12:11:07.053518+00:00 app[web.1]: Dec 28, 2013 12:11:06 +0000 NewRelic 1 INFO: Setting protocol to "https" | |
2013-12-28T12:11:07.409930+00:00 app[web.1]: Dec 28, 2013 12:11:07 +0000 NewRelic 1 INFO: Configuration file is /app/newrelic.yml | |
2013-12-28T12:11:07.431577+00:00 app[web.1]: Dec 28, 2013 12:11:07 +0000 NewRelic 1 INFO: New Relic Agent v3.2.0 has started | |
2013-12-28T12:11:07.431801+00:00 app[web.1]: Dec 28, 2013 12:11:07 +0000 NewRelic 1 INFO: Agent class loader: sun.misc.Launcher$AppClassLoader@6b38dba | |
2013-12-28T12:11:07.431577+00:00 app[web.1]: Dec 28, 2013 12:11:07 +0000 NewRelic 1 INFO: Java version: 1.7.0_45 | |
2013-12-28T12:11:14.332682+00:00 heroku[web.1]: source=web.1 dyno=heroku.1962 | |
2013-12-28T12:11:20.236798+00:00 heroku[web.1]: State changed from starting to up | |
2013-12-28T12:11:19.830833+00:00 app[web.1]: INFO org.eclipse.jetty.server.Server - jetty-8.1.9.v20130131 | |
2013-12-28T12:11:19.903306+00:00 app[web.1]: Dec 28, 2013 12:11:19 +0000 NewRelic 1 INFO: Server Info: jetty/8.1.9.v20130131 | |
2013-12-28T12:11:19.982817+00:00 app[web.1]: INFO o.e.jetty.server.AbstractConnector - Started [email protected]:20987 | |
2013-12-28T12:11:21.210603+00:00 app[web.1]: INFO io.pedestal.service.http - {:line 64, :msg "GET /"} | |
2013-12-28T12:11:23.502916+00:00 app[web.1]: Dec 28, 2013 12:11:23 +0000 NewRelic 9 INFO: Collector redirection to collector-7.newrelic.com:443 | |
2013-12-28T12:11:23.753969+00:00 app[web.1]: Dec 28, 2013 12:11:23 +0000 NewRelic 9 INFO: Agent run id: 683712260 | |
2013-12-28T12:11:23.754626+00:00 app[web.1]: Dec 28, 2013 12:11:23 +0000 NewRelic 9 INFO: Agent 2@2c9/Example App connected to collector.newrelic.com:443 | |
2013-12-28T12:11:23.765569+00:00 app[web.1]: Dec 28, 2013 12:11:23 +0000 NewRelic 9 INFO: Real user monitoring is enabled with auto instrumentation for application "Example App" | |
2013-12-28T12:11:23.769471+00:00 app[web.1]: Dec 28, 2013 12:11:23 +0000 NewRelic 9 INFO: Errors will be sent to New Relic for Example App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:dependencies
doesn't have to be extended, only:java-agents
.