Yesterday I talked about how I was able to customise the capture of custom metric data in AppDynamics. Part of that project involved installing and setting up NewRelic as well, for comparing the two enterprise products. Similar to AppDynamics, I needed to figure out how to implement the same kind of logging of custom metrics and implement them in a ColdFusion application. Using their Java Agent API library makes this very easy.

Reading through the NewRelic documentation on how to capture Java specific attributes, I realised what I needed to implement was the addCustomParameter() method. That function is overwritten in their Java class, one accepting a string for its value and the other a number, so keep that in mind when you are passing values to the logger as it implies only strings and numbers can be captured.

First I made sure to add the Java Agent JAR in my ColdFusion lib folder, and then restarted the app to load its contents; I then had access to the namespace com.newrelic.api.agent.NewRelic. I created a component, to act as a singleton, which captures the addCustomParameter() method.

I could then create an instance of this component and pass a custom structure of key-value pairs to it for logging.

My custom data then became available through their New Relic Query Language (NRQR), and I was able to mix them with their custom data to create awesome dashboards. Management bedazzled, check.

I must admit I found NewRelic’s implementation and documentation a little more straight forward than AppDynamics’, but they both get the job done is a very similar way.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.