AppDynamics Application Intelligence Platform

3.8.x Documentation

PDFs

Videos

Release Notes

This topic provides some guidance and examples of the correct syntax for using getter chains in AppDynamics configurations.

Using Getter Chains

You can use getter chains to:

Note: If a getter chain calls on a method that does a lot of processing, such as making numerous SQL calls, it can degrade the performance of the application and the App Agent for Java. Ideally, use getter chains only with simple MBean gets.

An example of a simple getter would be just getting a property from a bean, such as getName().

public class MyBean
{
private String name;
public void setName(String name)
{ this.name = name; }
public String getName()
{ return this.name; }
public String getValue()
{ // Open up a database connection and run a big query // Process the result set performing some complex maths on the data // etc. return calculatedValue; }
}

Separators in Getter Chains

The following special characters are used as separators:

  • comma (,) for separating parameters
  • forward slash (/) for separating a type declaration from a value in a parameter
  • Dot (.) for separating the methods and properties in the getter chain
  • Dot (.) when representing "anything" must be escaped.

Escaping Special Characters

  • If a slash or a comma character is used in a string parameter, use the backslash (\) escape character.
  • If a literal dot (.) is used in a string parameter, use the backslash escape character before the dot. For example, a dot (.) when representing any character must be escaped using the backslash (\) escape character.

For example, in the following getter chain, both the backslash (\)  and the dot (.) are escaped.

getHeader(hostid).split(\\\.).[1]

Values Passed in a Getter Chain

The value passed in a getter chain is always a string unless cast to another type. The following supported types default to java.lang.String.

  • int
  • float
  • boolean
  • long
  • object

Getter Chain Examples

  • Getter chain with integer parameters in the substring method using the forward slash as the type separator:

    getAddress(appdynamics, sf).substring(int/0, int/10)
    
  • Getter chain with various non-string parameter types:

    getAddress(appdynamics, sf).myMethod(float/0.2, boolean/true, boolean/false, int/5)
    
  • Getter chain with forward slash escaped; escape character needed here for the string parameter:

    getUrl().split(\/) # node slash is escaped by a backward slash
    
  • Getter chain with an array element:

    getUrl().split(\/).[4]
    
  • Getter chain with multiple array elements separated by commas:

    getUrl().split(\/).[1,3]
    
  • Getter chain retrieves property values, such as the length of an array:

    getUrl().split(\.).length
    
  • Getter chain using backslash to escape the dot in the string parameter;
    the call is getParam (a.b.c).

    getAddress.getParam(a\.b\.c\.)
    
  • In the following getter chain, the first dot requires an escape character because it is in a string method parameter (inside the parentheses). The second dot does not require an escape character because it is not in a method parameter (it is outside the parentheses).

    getName(suze\.smith)getClass().getSimpleName()
  • Getter chains that return Hashmap values:

    get(object/myvalue).substring(int/0,int/10) 
    get(object/ACTION)
  • The following getter chain is from a transaction splitting rule on URIs that use a semicolon as a delimiter; for example:

/my-webapp/xyz;jsessionid=BE7F31CC0235C796BF8C6DF3766A1D00?act=Add&uid=c42ab7ad-48a7-4353-bb11-0dfeabb798b5

The getter chain splits on the API name, so the resulting split transactions are "API.abc", API."xyz" and so on.

The call gets the URI using getRequestURI() and then splits it using the escaped forward slash. From the resulting array it takes the third entry (as the split treats the first slash as a separator) and inserts what before the slash (in this case, nothing) into the first entry. Then it splits this result using the semicolon, getting the first entry of the resulting array, which in this case contains the API name.

getRequestURI().split(\/).[2].split(;).[0]

 

Tip: When using string.split(), remember that it takes a regex and you have to escape any special regex characters.

For example, if you want to split on left square bracket ([):

Java syntax: split("
[")
Getter chain syntax: split([)

Braces Enclosing Getter Chains

In most cases braces  are not used to enclose getter chains in AppDynamics configurations. An exception is the use of a getter chain in a custom expression on the HTTPRequest object.

Custom expressions on the HTTP request are configurable in the Java Servlet Transaction Naming Configuration window and in the Split Transactions Using Request Data tab of the servlet custom match and exclude rules. In these cases, braces are required to delineate the boundaries of the getter chains.

Getter chains in custom expressions on the HTTP request in diagnostic data collector should also be enclosed in braces:

Learn More