Naming Transactions
If a transaction has a name, OPE displays the name in diagrams. Naming your transactions makes it easier to find your way through complex application traces.
There are several ways to name transactions using the ObjectStore API. These methods are described in the appropriate ObjectStore API documentation and in the following sections.
Using Transaction Macros
You can use the following OS_BEGIN_TXN macros:
The transaction is automatically named according to the pattern
- OS_BEGIN_TXN( < identifier>,< expression>,< txn-type>,char*)
< identifier>: source file name: source file line numberThe transaction The last argument to the macro is the name of the transaction. The maximum length of this string is 48 characters.
- OS_BEGIN_TXN_NAMED( < identifier>,< expression>,< txn-type>,
Using Dynamic Transactions
You can name dynamic transactions by calling the following method defined in class os_transaction:
static os_transaction *begin(
char* name,
transaction_type_enum = update,
transaction_scope_enum = local,
os_transaction *parent);In this overloading of os_transaction::begin, the first parameter is the name of the transaction.
You can use objects of the os_transaction class for many transactions by calling the static begin and end functions. The transaction name is a property of the os_transaction object and all transactions of this object have the same name unless you change it.
You should give different names to transactions that perform different types of processing. This helps you identify them in the application trace. However, if you change a name during a , it is not shown to OPE until the beginning of the next transaction.
You can also change the name of an existing transaction object with the set_name function or determine the name of a transaction object with these methods:
- void os_transaction::set_name(const char*);
- char* os_transaction::get_name();
//caller must delete the resultNote that OPE cannot determine if transaction names change during the transaction. Thus, the after-event of the transaction does not reflect the change, and the original transaction name is displayed.