Start a Transaction Using OOTB Servlet Naming Rules

The following example shows how to leverage automatic servlet naming rules to name a transaction:

public String checkout(List<ItemOrders> orders) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("header1", "headerValue1");
Map<String, String[]> parameters = new HashMap<String, String[]>();
Map<String, Object> cookies = new HashMap<String, Object>();
cookies.put("chip", "ahoy");
ServletContext.ServletContextBuilder contextBuilder = new ServletContext.ServletContextBuilder()
.withURL(new URL("https://www.yourstore.com/endpoint/to/checkout"))
.withParameters(parameters)
.withHeaders(headers)
.withCookies(cookies)
.withSessionAttributes(new HashMap<String, Object>())
.withRequestMethod("GET")
.withHostValue("hostValue")
.withHostOriginatingAddress("hostOriginatingAddress");
Transaction t = AppdynamicsAgent.startServletTransaction(contextBuilder.build(), EntryTypes.HTTP, null, false);
/*******************
* Method Body Here
*******************/
t.end();
}