Getter chains provide basic programmatic functions to let you access application data for use in data collector and business transaction configuration. This topic describes the getter chain syntax for the .NET Agent and provides examples to help you get started.
Configurations that support getter chains include:
If a getter chain calls a heavy processing method, such as one that makes numerous SQL calls, the getter chain may degrade performance for both the application and the .NET Agent. When possible, use getter chains only with simple
For example, a simple getter that returns a property for a class, such as
Special Characters in Getter Chains
The following special characters are used as separators:
()for enclosing parameters
,for separating parameters
- forward slash
/for separating a type declaration from a value in a parameter
.for separating the methods and properties in the getter chain
Getter chains also treat spaces at the beginning or end of a string as special characters.
If the getter chain should treat a special character literally, escape it using a backslash:
\. For parentheses, you only need to escape the closing parenthesis in a string.
Declare Parameter Types
The .NET Agent identifies parameter types as follows:
- Dictionaries, anything with property accessors, use a normal parameter set, which defaults to string.
- Arrays use single integers as parameters.
string/0 if you have a hash, or anything that translates to
get_Item (any kind of property).
int/0 if you have an array.
When your getter chain uses a method with parameters other than the default type, you need to declare the parameter type.
The following example demonstrates how to declare the parameter types to resolve the overloaded
Susbstring()method. The forward slash serves as the type separator.
For instance, if
GetAddress(appdynamics, sf)returns "303 2nd St, San Francisco, CA 94107", the full getter chain expression returns "303 2nd St".
The following example shows how to declare the parameter types for a user-defined method that takes a float parameter, a boolean parameter, and an integer parameter. The forward slash serves as the type separator.
Escape a Character
When you want to use one of the reserved separator characters as part of a string, you must escape the character.
The following example shows the how to escape the dot in the string parameter.
The agent executes
GetParam("a.b.c.")on the result of
GetAddress()and returns the value of of the parameter.
In the following example, the first dot is part of the string method parameter, which requires an escape character. The second and third dots don't require an escape character because they are used as method separators.
The following example shows how to escape the closing parenthesis in a search for "()" within a string.
Access Indexed Properties and Dictionary Values
If your getter chain accesses a dictionary object, you can access the values using the following syntax:
The following example returns the value for the key "suze.smith".
The following example returns the value for the key "suze.smith" using the implied getter.
Split a Character Array
If you want to access the various segments of a URL, you will need to treat it as a character array:
The following example splits a URL on the forward slash character. In this case the first slash acts as a type separator. The getter chain returns the fourth item in the array.
The agent returns "Search" when it applies the getter chain to the following URL:ple.com/Search/Airfare
The following example splits on the forward slash character, then returns the length property of the resulting array.
The following example illustrates a transaction splitting rule for URIs that use a semicolon delimiter. The getter chain splits on the forward slash, then splits the fourth element on the semicolon.
The agent returns "create-user" when it applies the getter chain to the following URL:
Compose Getter Chains for HttpRequest Objects
The .NET Agent requires special syntax for getter chains on System.Web.HttpRequest objects in ASP.NET WebForms, MVC, and MVC WebAPI applications.
Use the following syntax to delineate the boundaries of the getter chain:
The following example determines the user principal:
Places to use this syntax include:
- HTTP Request Data Collectors
- ASP.NET Transaction Detection custom expressions