Highlighted
Contributor.
Contributor.
2681 views

How to set the transaction time programatically using Truclient?

Jump to solution

I wish to capture the execution time of a backend processing job and show this as a transaction in the Analaysis report. We have a UI page that display the backend job start time and completed time. I can probably write some javascript code to extract information from this UI page and evaluate the job execution time, then output the execution time in the vugen log. But I wish to also see this as a transaction in the Analysis report. Is there a way this can be done? 

It would be great if we can programatically set the transaction time.

Thanks!
Jason

0 Likes
1 Solution

Accepted Solutions
Highlighted
Contributor.
Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

Thanks Shiomi! 

The suggested solution work except I had to do little tweak in the c function. Problem is with the 'LR_PASS'. 
it compliles fine but when I played the script, it failed with the following error.

Error: CCI compilation error -d:\epim\performance\scripts\campaigns\epim_cm007_campaign_export\\pre_cci.c: C-functions.c:15: error: undeclared identifier `LR_PASS'.
Error: CCI compilation error -d:\epim\performance\scripts\campaigns\epim_cm007_campaign_export\\pre_cci.c: C:\\Program Files (x86)\\HP\\LoadRunner\\include/lrun.h:565: warning: declaration of `lr_eval_string' does not match previous declaration at C-functions.c:15.

I ended up using parameter for the status value:

lr_set_transaction(lr_eval_string("{LRP_TXN_NAME}"), atoi(lr_eval_string("{LRP_ELAPSED_TIME}")), atoi(lr_eval_string("{LRP_STATUS}")));

Thanks!
Jason

View solution in original post

6 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

Hi Jason,

Yes, it is doable. With TruClient specifically it requires a bit more effort than with other protocols.

For any other protocol you can lr_set_transaction API

This specific API was not exposed in TruClient JavaScript API hence you can use it only from the C function section of the script.

Here are the steps you should take to implement it

1.  Add a function in the script C-functions file to report the transaction

 

void reportTransaction()
{
        // myTrans is the transaction name. 
// Duration is a parameter that will be defined in the JavaScript level and hold the duration
lr_set_transaction("myTrans", atoi(lr_eval_string("{Duration}")), LR_PASS); }

2. in TruClient sidebar add an Evaluate JavaScript step to populate the Duration parameter with the transaction duration

// The value in this case is just for the sake of the example
TC.setParam("Duration", Math.round(Math.random() * 100));

3.  In TruClient sidebar add an Evaluate C function step and call to reportTransaction function

Let me know if you have further questions

Regards,

Shlomi

 

 

 

Highlighted
Contributor.
Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

Thanks Shiomi! 

The suggested solution work except I had to do little tweak in the c function. Problem is with the 'LR_PASS'. 
it compliles fine but when I played the script, it failed with the following error.

Error: CCI compilation error -d:\epim\performance\scripts\campaigns\epim_cm007_campaign_export\\pre_cci.c: C-functions.c:15: error: undeclared identifier `LR_PASS'.
Error: CCI compilation error -d:\epim\performance\scripts\campaigns\epim_cm007_campaign_export\\pre_cci.c: C:\\Program Files (x86)\\HP\\LoadRunner\\include/lrun.h:565: warning: declaration of `lr_eval_string' does not match previous declaration at C-functions.c:15.

I ended up using parameter for the status value:

lr_set_transaction(lr_eval_string("{LRP_TXN_NAME}"), atoi(lr_eval_string("{LRP_ELAPSED_TIME}")), atoi(lr_eval_string("{LRP_STATUS}")));

Thanks!
Jason

View solution in original post

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

Excellent. Glad to hear.

 

0 Likes
Highlighted
Contributor.
Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

Yes, it works with the tweak. I am curious why it gave the error with 'LR_PASS'. Would you know?

Thanks!
Jason

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

I guess there is a need to include a header file that holds this constant definition. I admit I didn't have time to test and run the code myself 🙂

0 Likes
Highlighted
Contributor.
Contributor.

Re: How to set the transaction time programatically using Truclient?

Jump to solution

No problem. I have something that works now. ::-)

Thanks!
Jason

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.