I recently helped set up AppDynamics for a client who needed to track and log their application requests on an Enterprise scale. Although AppDynamics captures a ton of information for every request that I could then use to create Snapshot dashboards of tables and charts, the client wanted to personalise things a little more by being able to add custom metrics to each request and have that available for the dashboards through their query language. For example, they wanted to add anonymous user data to each request like transaction amounts and guest counts that would help drive and display marketing campaigns and charts. Since AppDynamics comes in Java, it was fairly easy to hook into the class implementations and expose this functionality in ColdFusion.
There is a file called javaagent.jar that comes bundled as part of the AppDynamics installation and the CF JVM needs that to make this work, so make sure you add it to your JVM arguments. Then you also need to add the library folder of all the AppDynamics JAR files and make them available to the CF runtime. I normally use CommandBox and server.json config files for the CF servers, so I can just define both of those variables there. If you are not using that method, alternatively you can register those paths in the THIS.javaSettings of your Application.cfc.
The actual classes that implement adding custom metrics are implemented under the namespaces com.appdynamics.apm.appagent.api.AgentDelegate and com.appdynamics.apm.appagent.api.DataScope, while the main Java method is com.appdynamics.apm.appagent.api.AgentDelegate.getMetricAndEventPublisher().addSnapshotData(). Based on those two classes I created a singleton class which implements and wraps the logging functionality around them.
To use this class, I first make an instance of it and then pass a CF structure of any custom data I want to save to the addData() function.
After I did this the custom metrics were available in the AppDynamics query language under the namespace segments.userData. When I then created a dashboard display and used their pseudo-SQL to query the stored data, I could see my custom metrics as part of what is available.
AppDynamics seems to use the first property value passed in to determine which type to use for storage (i.e. boolean, numeric, string, etc), so it’s important that you set things right to begin with. What I did is I created a struct with proper examples for each variable type and run that once for the production AppDynamics instances to properly set the types – then everything worked as expected.