Split Transactions on XPath Expression
You can access values in an XML payload for business transaction naming or splitting using an XPath expression. Consider the following example from an Ecommerce order transaction where the XML represents an order for three items. The order uses credit card processing, which is the distinguishing element for this body:
<acme>
<order>
<type>creditcard</type>
<item>Item1</item>
<item>Item2</item>
<item>Item3</item>
</order>
</acme>
The URL is:
http://acmeonline.com/store
The doPost()
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
DocumentBuilderFactory docFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse(req.getInputStream());
Element element = doc.getDocumentElement();
//read the type of order
//read all the items
processOrder(orderType,items)
...
}
Imagine you want to differentiate "Order" transactions based upon the type of order. You can use the XPath expression //order/type creditcard
- On the Rule Configuration tab, click Split transactions using XML/JSON Payload or a Java method invocation.
- Choose XPath Expressions for the Split Mechanism.
- Enter the XPath expression that points to the value of the XML element to use for naming. In this example,
//order/type
The agent appends the value of the XPath expression to the name of the business transaction, for example, Store.order.creditcard doPost()
You can use one or more XPath expressions to chain the names generated for the Business Transaction.
You can specify whether the request results in transaction splitting when the expression does not evaluate to a value.