Monitoring your application locally with NewReclic

How to connect your application to NewRelic


Feb 9, 2018 1 minutes read

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:

 <dependency>
    <groupId>com.newrelic.agent.java</groupId>
    <artifactId>newrelic-api</artifactId>
    <version>3.47.0</version>
    <scope>provided</scope>
</dependency>

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

Download java agent:

NEWRELIC_VERSION=3.47.0

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

Run your application

NEW_RELIC_NO_CONFIG_FILE=true
NEW_RELIC_APP_NAME="My App Local"
NEW_RELIC_LICENSE_KEY=XXXXXXXXXXXX
NEW_RELIC_LOG=stdout

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);

References:

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: https://github.com/jemalloc/jemalloc

Chronicle

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