Custom LoadRunner Transaction Reporting

This article will detail a means of reporting on long-running, problematic transactions using a custom C function.

If you discover a particular transaction that appears to have a high deviation of response time (for example through its standard deviation or percentile profile), you’ll probably want to find out what’s causing it. For example, you might have a generic search transaction whose parameter data covers hundreds of search items. You could embed the a search item ID to dynamically construct your transaction name, but you could then be facing an long, arduous analysis process to find the culprit. If your AUT is Web-based, you could also use Web Page Diagnostics but you’re limited to a 10% sample rate and there’s still work to do to get the information out of Analysis. Neither of these methods lend themselves to real-time test analysis, either.

A neat way of alerting you to poorly performing transactions in real-time is to create a reusable, custom C function that examines transaction response times and creates an error if that response time exceeds a configurable threshold. This method will present real-time succinct information in a single place (the error console), allowing you to proactively investigate the issue without potentially trawling through hundreds of Vuser logs. If you’re using the Send messages only when an error occurs runtime option, you also have the benefit of the Vuser log leading up to the error. Post-test, you can view the error console in Analysis or filter Vuser logs.

Step 1 – Create transactions.c File

void reportTransaction(
  double <a href="">real online blackjack</a> dThreshold, //The duration threshold, in seconds
  char *sTranName, 	 //The name of the transaction
  char *sIdentifier  //Some identifier that's useful to your context
) {
  double dTranDuration; //The duration of the transaction
  int    iVUserId;      //The current vuser ID

  //Get transaction duration
  dTranDuration = lr_get_transaction_duration(sTranName);

  //If equal to or above threshold, format and report an error
  if(dTranDuration >= dThreshold) {
    lr_whoami(&iVUserId, NULL, NULL);
    lr_save_datetime("%d/%m/%y %H:%M:%S", DATE_NOW, "p_reportTransaction_date_time");

      "Report transaction: %s, %s, %f, %s",

Note char *sIdentifier should be an identifier applicable to your context, like a unique session ID or term that enables you to investigate further.

Step 2 – Include transactions.c File

Include the file above in your scripts using the #include complier directive so that you need only maintain one copy of this file. For example, in vuser_init(), you may use a UNC path to a common location:

 #include "\\scripthost\vugen\transactions.c"



Step 3 – Integrate Function

In your script, call reportTransaction() with the appropriate arguments directly before you end the transaction. For example, using the search example:




  reportTransaction(10, "Search", lr_eval_string("{p_search_term}");
  lr_end_transaction("Search", LR_PASS);


So, if the Search transaction is equal to, or longer than, 10 seconds, your script will send an error in the following format (which is nicely delimited for any post text processing you may want to do):

20/09/11 20:33:14, Search, 13.43, TheSearchTerm

A couple of things to note here – this implementation assumes the Fail open transactions on lr_error_message is disabled. You can of course extend this implementation to cater for multiple scenarios and behaviours.

Leave a Reply

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