Create Business Transactions With an Alternate Application Context

You can create a business transaction with an alternate application context using appd_bt_begin_with_app_context() and appd_bt_end() calls. In addition to the parameters passed to appd_bt_begin(), the appd_bt_begin_with_app_context() also takes an application context name string, as defined by the call to appd_context_config_init().

appd_bt_begin_with_app_context() returns a handle to use in subsequent routines that affect that business transaction.

The following example demonstrates setting a business transaction with an alternate application context:

// create the alternate application context
appd_context_config* cfg2 = appd_context_config_init("My_Context");
...
// add additional setter commands to initialize the alternate application context
appd_context_config_set_controller_account(cfg2, ac.second.ac_account_get().c_str());
appd_context_config_set_controller_access_key(cfg2, ac.second.ac_access_key_get().c_str());
appd_context_config_set_controller_host(cfg2, ac.second.ac_host_get().c_str());
appd_context_config_set_controller_port(cfg, ac.second.ac_port_get());
appd_context_config_set_controller_use_ssl(cfg2, ac.second.ac_use_ssl_get() ? 1 : 0);
appd_context_config_set_app_name(cfg2, ac.second.ac_app_get().c_str());
appd_context_config_set_tier_name(cfg2, ac.second.ac_tier_get().c_str());
appd_context_config_set_node_name(cfg2, ac.second.ac_node_get().c_str());
// initialize the alternate application context
appd_sdk_add_app_context(cfg2);
// start the "Checkout" transaction with the alternate application context
appd_bt_handle btHandle = appd_bt_begin_with_app_context("My_Context", "Checkout", NULL);
// end the transaction
appd_bt_end(btHandle);

When the business transaction ends, via a call to appd_bt_end(), the agent stops reporting metrics for the business transaction. Between starting and ending the transaction, you can perform operations such as adding errors to the business transaction, defining the transaction snapshot attributes, adding backends and exit calls, and so on.