Business Transaction Management
start_bt(name,correlation_header=None)
Starts a business transaction of the specified name.
There can only be one active business transaction per thread. Attempts to start subsequent business transactions in the same thread will return None.
Returns a BtHandle on starting the transaction or None if no transaction was started.
name: str
Name of the business transaction being started. The following characters cannot be used in
business transaction names: { } [ ] | & ;
correlation_header: str, optional
If specified, a correlation header that has been generated by another AppDynamics agent and passed to this agent as a string. A correlation header provides information to enable this transaction to correlate with a transaction that is upstream to this one.
end_bt(bt_handle,exc=None)
Ends the business transaction identified by bt_handle.
bt_handle: BtHandle
Identifies the business transaction being ended. The handle is returned by start_bt().
exc: Exception (list of Exceptions), optional
exc: Exception (list of Exceptions), optionalIf an exception occurred during processing this business transaction that you have caught
with a try-except block, and you wish to report the exception as part of the business
transaction, pass the exception as the exc
.
If Multiple exceptions
are part of the same business transaction and you wish to report all of them, pass the list
of exceptions as the exc
.
add_snapshot_data(bt_handle,key,value)
Attaches custom data to transaction snapshots generated for the business transaction identified by bt_handle.
The custom data is exposed in the USER DATA
tab of the transaction
snapshot details in the Controller UI.
The custom data is added to the business transaction but reported only when a transaction snapshot is generated. See Troubleshoot Business Transaction Performance with Transaction Snapshots for information on when transaction snapshots are generated.
bt_handle: BtHandle
Identifies the business transaction to which custom data is added. The handle is returned by start_bt().
key: bytes or unicode
Name of the data item to be reported in the snapshot.
If passed as bytes, the buffer must represent a UTF-8 encoded string.
value: any
Value of the data.
All other objects are converted to str(value)
.
get_active_bt_handle(request)
Returns a BtHandle to the business transaction associated with the request object or None if no such business transaction was found.
This is useful for passing a business transaction handle to another API function, such as
start_exit_call()
when the business transaction was created by the
default Python Agent instrumentation rather than through the APIs.
request object
The request object associated with an active business transaction. Varies depending on the framework in which the business transaction was started.
See the documentation for the applicable framework to find out how to get the request object.
Framework | Documentation for the Request Object |
---|---|
Flask | https://flask-cn-doc.readthedocs.io/en/latest/reqcontext.html |
Django | https://docs.djangoproject.com/en/1.8/ref/request-response/ |
CherryPy | https://cherrypy.readthedocs.io/en/latest/basics.html |
WSGI environ | https://www.python.org/dev/peps/pep-0333/ |