RSS

Monitoring Transactions by emulated location at runtime using VED and Vugen script – Part 1

Wed, Jun 10, 2009

Staff Posts, Tips and Tricks

The Analysis application of LoadRunner 9.5 allows grouping transactions by emulated location. This enables users to see how each transaction performs in different locations. This is a very valuable feature but it is only available at analysis time, after the test stopped. In this post I’ll show how simple changes to the vugen scripts allow monitoring transactions from different locations, while the test is running. This is by no means a complete solution but it’ll show you the general idea behind it.

In this solution I’m taking advantage of the “User Data Point” mechanism in LoadRunner. The “User Data Point” mechanism allows users to include their own custom data points in the LoadRunner test database. These data points are viewable in the LoadRunner Controller UI when the test runs and in the analysis.

The main idea is that for each transaction reported to the controller, the script will also report a “User Data Point”. The data point will include the name of the emulated location or host machine. Adding the host name will guaranty uniqueness of the data point name and will allow pinpointing the location it comes from. If you are worried about performance costs associated with using many data points with multiple virtual users, you can implement a caching mechanism for each location that collects these data points and reports their averages as data points every second or so.

In my script I define StartTransaction and EndTransaction functions and replace all instances of lr_start_transaction and lr_end_transaction with them. These functions call the appropriate lr_ function internally and EndTransaction() also reports the data point. Although StartTransaction just calls lr_start_transaction, it’s a good idea to use it as it keeps the code clean and allows for easy modifications.

One note: I’m using “Host name” and not “Emulated Location” in the script because there is currently no API to get the emulated location name using a script.

Here is how the two functions are defined:

// Encapsulate lr_start_transaction() – for consistency with EndTransaction()

intStartTransaction( char* pName )

{

return lr_start_transaction( pName );

}

// Encapsulate lr_end_transaction(). Measures TRT and status and inserts

// a user data point that includes the host name – to distinguish the same transaction

// coming from other hosts.

int EndTransaction( char* pName, int status )

{

double dTransTime = 0;

int iTransStatus = 0;

char pDataPointName[1024] = {0};

int iRetVal = 0;

// Get the duration of the transaction.

dTransTime = lr_get_transaction_duration(pName );

// Get the status of the transaction.

iTransStatus = lr_get_transaction_status( pName );

// Signal the end of the transaction to LoadRunner.

iRetVal = lr_end_transaction( pName, status );

// If the transaction completed correctly, add it’s instance as a data point

if ( dTransTime > 0 && iTransStatus == LR_PASS && ( status == LR_PASS || status == LR_AUTO ) )

{

// Add the host name.

sprintf( pDataPointName, “%s::%s”, lr_get_host_name(), pName );

// Add the user data point.

lr_user_data_point( pDataPointName, dTransTime );

}

return iRetVal;

}

Here is an example of Action transaction that uses the new functionality:

Action()

{

/* … Removed beginning of script for clarity … */

//Signal a transaction start

StartTransaction( “Second Download” );

web_url(“testpage.asp_2″,

“URL=http://10.0.0.2/testanalyzer/testpage.asp”,

“Resource=0″,

“RecContentType=text/html”,

“Referer=http://10.0.0.2/”,

“Snapshot=t7.inf”,

“Mode=HTML”,

LAST);

web_link(“download 1000 bytes with 1 second delay”,

“Text=download 1000 bytes with 1 second delay”,

“Snapshot=t8.inf”,

LAST);

// Signal a transaction end.

EndTransaction( “Second Download”, LR_AUTO );

return 0;

}

When the test runs each transaction appears in the “Transaction Response Time” graph of LoadRunner but it’s value is aggregated for all locations. Using the StartTransaction / EndTransaction functions above you get the TRTs from each location in the data point graph aggregated only for virtual users running on that location. This allows you to see how each transaction performs from different emulated location.

Stay tuned as In a few weeks I’m planning to post another article detailing how to add bandwidth and latency to the mix and get a better view of how the network affects your users.

, , , , , ,

share

1 Comments For This Post

  1. Amichai Lesser Says:

    Danny, welcome to the APMBlog. Great post to debut with. Looking forward for more articles.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes