Monitoring your application locally with NewReclic

How to connect your application to NewRelic

The New Relic Digital Intelligence Platform provides actionable insights to drive digital business results. You can monitor your application and infrastructure performance so you can quickly resolve issues and improve digital customer experiences.

Following instruction should help you to connect your application to NewRelic platform and customize application events sent to the platform.

Add Newrelic API classess to your project’s pom.xml:


If you want to run your application without newrelic agent, then use compile scope.

Download java agent:


if [ ! -d bin/newrelic ]; then
    echo "NewRelic agent binary not found. Downloading one"
    mkdir -p bin/newrelic
    mvn dependency:get${NEWRELIC_VERSION}:zip
    unzip ~/.m2/repository/com/newrelic/agent/java/newrelic-java/${NEWRELIC_VERSION}/newrelic-java-${NEWRELIC_VERSION}.zip -d ./bin

Run your application


java -jar -server -javaagent:./bin/newrelic/newrelic.jar myapp.jar

Now you can publish custom error events to NewRelic using Java API:

NewRelic.noticeError("Something really scary has happened...", false); // unexpected condition

NewRelic.noticeError(new RuntimeException("my exception"), true); // expected exception

NewRelic.addCustomParameter("customString", "bar");

NewRelic.addCustomParameter("customNumber", 1);


See Also

Video: Scalable Memory Allocation using jemalloc Tech Talk (1/11/2011)

Video: Scalable Memory Allocation using jemalloc - Tech Talk (1/11/2011) jemalloc project:


Chronicle by Peter Lawrey: This library is an ultra low latency, high throughput, persisted, messaging and event driven in memory database. The typical latency is as low as 80 nano-seconds and supports throughput of 5-20 million messages/record updates per second. This library also supports distributed, durable, observable collections (Map, List, Set) The performance depends on the data structures used, but simple data structures can achieve throughput of 5 million elements or key/value pairs in batches (eg addAll or putAll) and 500K elements or key/values per second when added/updated/removed individually.

JVM Profiling Mode

There is no sense to run profiler in instrumentation mode on a high load. Instead of using instrumentation you should use sampling mode. This article describes the difference between instrumentation and sampling modes. JVisualVM is a good free tool for this task.

logo   Never miss a story, subscribe to our newsletter