Handling Business Transaction Code Executing in a Loop
For a script-based CLI application that executes in a loop, perhaps fetching items from a
database or remote service, you may want the agent to detect every iteration of the loop as a
separate business transaction. In this case, enclose the code inside the loop within
appdynamics_start_transaction()
and
appdynamics_end_transaction()
calls.
If you do not do this, the agent will aggregate each iteration through the loop into a single business transaction.
In the following example, the agent detects a business transaction named
getItem
for every iteration.
while (true){
appdynamics_start_transaction("getItem", AD_CLI);
//your code goes here
. . .
appdynamics_end_transaction();
}