Configure Method Data Collectors
2 minutesMethod invocation data collectors capture code data such as method arguments, variables, and return values. If HTTP data collectors don’t have sufficient business data, you can still capture these information from the code execution.
In this exercise you will perform the following tasks:
- Discover methods.
- Open a discovery session.
- Discover method parameters.
- Drill down to an object within the code.
- Create a method invocation data collector.
- Validate analytics on method invocation data collectors.
Open a Discovery Session
You may not have an application developer available to identify the method or parameters from the source code. However, there is an approach to discover the application methods and objects directly from AppDynamics.
- Select the Applications tab at the top left of the screen.
- Select Supercar-Trader-YOURINITIALS application
- Select the Configuration tab.
- Click on the Instrumentation link.
- Select the Transaction Detection tab.
- Click on the Live Preview Button on the tight.
- Click on Start Discovery Session button
- Select the Web-Portal Node in the pop-up windows. It should be the same node that the method you are investigating runs on
- Click Ok
- Select Tools on the right toggle.
- Select Classes/Methods in the drop-down list.
- Select Classes with name in the Search section.
- Type in the class name supercars.dataloader.CarDataLoader in the text box. To find the class name you can search through call graphs, or ideally find it in the source code.
- Click Apply to search for the matching class methods.
- Once the results appear, expand the class that matches your search.
- Look for the same method saveCar.
Note that the saveCar method takes a CarForm object as an input parameter.
Drill Down to the Object
Now you have found the method, explore its parameters to find out where you can pull the car details properties.
You saw that saveCar method takes the complex object CarForm as an input parameter. This object will hold the form data that was entered on the application webpage. Next, you need to inspect that object and find out how you can pull the car details from it.
- Type in the class name of the input object supercars.form.CarForm in the text box
- Click Apply to search for the class methods.
- When the results appear, expand the supercars.form.CarForm class that matches the search.
- Look for the methods that will return the car details that you want. You will find get methods for price, model, color, and more.
Create Method Invocation Data Collector
With the findings from the previous exercises, you can now configure a method invocation data collector to pull the car details directly from the running code in runtime.
- Select the Applications tab.
- Select Supercar-Trader-YOURINITIALS Application
- Select the Configuration tab.
- Click on the Instrumentation link.
- Select the Data Collectors tab.
- Click Add in the Method Invocation Data Collectors.
We will create a method invocation data collector to capture the car details.
- For the Name, specify SellCarMI-YOURINITIALS.
- Enable Transaction Snapshots.
- Enable Transaction Analytics.
- Select with a Class Name that.
- Add supercars.dataloader.CarDataLoader as the Class Name.
- Add saveCar as the Method Name.
Then as observed, the Input Parameter of Index 0 in SaveCar method was an on Object of Class CarForm, and then there is a Getter method inside that object that returns the car details properties such as getPrice().
So to explain that how we fetched that value in the MIDC, we will do the below:
- Click on Add at the bottom of the MIDC panel, to specify the new data that you want to collect.
- In the Display Name, specify CarPrice_MIDC
- In the Collect Data From, select Method Parameter of Index 0, which is our CarForm Object.
- For the Operation on Method Parameter, select Use Getter Chain. You will be calling a method inside CarForm to return the car details.
- Then specify getPrice(), the Getter method inside the CarForm class that will return the price.
- Click Save.
- Repeat the above steps for all the properties, including color, model, and any others that you want to collect data for.
- Save MIDC, and apply to the ”/Supercar-Trader/sell.do” business transaction.
The implementation of the MIDC requires that we restart the JVM:
- SSH into your EC2 instance
- Shutdown the Tomcat Sever
cd /usr/local/apache/apache-tomcat-9/bin
./shutdown.shIf you find any remaining application JVMs still running, kill the remaining JVMs using the command below.
sudo pkill -f Supercar-Trader- Restart the Tomcat Server
./startup.sh- Validate that the Tomcat server is running, this can take a few minutes
curl localhost:8080<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Apache Tomcat/9.0.50</title>
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<link href="tomcat.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper"
....Validate analytics on MD parameters
Go to the website and apply some manual load on the Sell Car Page by submitting the form a couple of times.
You will now verify if the business data was captured by HTTP data collectors in AppDynamics Analytics.
- Select the Analytics tab.
- Select the Searches tab and Add a new Drag and Drop Search.
- Click the + Add button and create a new Drag and Drop Search.
- Click + Add Criteria
- Select Application and Search For Your Application Name Supercar-Trader-YOURINITIALS
- Verify that the Business Parameters appear as a field in the Custom Method Data.
- Verify that the CarPrice Field has data.
Conclusion
You have now captured the business data from the Sell Car transaction from the node at runtime. This data can be used in the Analytical and Dashboard features within AppDynamics to provide more context to the business and measure IT impact on the business.








