Automatic transaction and timing name prefixes

In this post I will explain how to set up automatic transaction prefixes depending on various situations.
First let’s describe a situation where this would be needed. Imagine that you have several groups of users that use the same sub-sequence of scripts, e.g. Login scripts. Even though transactions are the same you may want to see the difference between Group #1 and Group #2 and if the transaction names are the same, this is not possible.
First thing we need to do is overload all transaction related methods. I will be only showing code for startTransaction method, as all other methods are very similar. We need to do this overloading in these files:

    void startTransaction(const string& transactionName);


    void startTransaction(const string& transactionName);

    // Dictionary for format tags and their values
    SimpleDataDictionary formatTags;

I will be creating a pattern based prefixing that I will be able to set in any of data sources available to user. This way I can provide control over names of transactions without interfering with code.
I will be using these format tags:

  • %VUGroupName% – The Virtual is vigrx plus safe User group name;
  • %VUScriptName% – Current running script name;
  • %VUIndex% – Virtual User index;
  • %Iteration% – Current iteration;
  • %TransactionName% – Passed transaction name;

As some of these variables don’t change at all, and some are available only in VirtualUserScript and not VirtualUser, we will have to set these variables accordingly.

void VirtualUserScript::startTransaction(const string& transactionName) {
    getVU().formatTags.setString("VUScriptName", getScriptName());
    getVU().formatTags.setString("Iteration", str(getCurrentIteration()));



void VirtualUser::pre() {
    // As Group Name and Index doesn’t change while running a test,
    // we need to only set this once, so we are doing this in VirtualUser::pre() method.
    formatTags.setString("VUGroupName", getVUName());
    formatTags.setString("VUIndex", str(getIndex()));

void VirtualUser::startTransaction(const string& transactionName) {
    // Setting last formatTag - this transaction's name
    formatTags.setString("TransactionName", transactionName);
    // By default only Transaction Name is used.
    string transactionFormat = getString("transactionFormat", "%TransactionName%");
    // We are using SimpleDataDictionary's makeSubstitutionsInto method to replace places
    // in transactionFormat (set in any of data sources) that match the pattern of %key%
    // with values that correspond to this key.

    // Now we need to call parent of this class to execute actual transaction method

You can repeat this for all transaction / timing methods you are using, the idea is the same just change code in few places.

Leave a Reply

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