.NET Notes and Examples

These sections apply to getter chains used in .NET Agent configurations.

Note: Escape backslashes within a getter chain for .NET with the double backslash.

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.

Therefore 0 string/0 get_Item 0 int/0

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.

    GetAddress(appdynamics, sf).Substring(int/0, int/10)

    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.

    GetAddress(appdynamics, sf).MyMethod(float/0\\.2, boolean/true, boolean/false, int/5)

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.
    UserDictionary.[string/suze\\.smith]
  • The following example returns the value for the key suze.smith using the implied getter.
    UserDictionary.get_Item(suze\\.smith)

Split by Character or Regular Expression Match in .NET Getter Chains

You can split values matched by character or as a string by matching a regular expression pattern. The result of a split operation is a string or character array that you can reference in your getter chain by an array index value.

The following examples illustrate how to use the character and string regular expression split operations in getter chains.

Split by Character

  • The following chain 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.

    GetUrl().Split(char[]//).[3]

    The agent returns "Search" when it applies the getter chain to the following URL: http://howdyworld.example.com/Search/Airfare

  • In the following example, the split occurs on the forward slash character, and the result is the length of the resulting array.

    GetUrl().Split(char[]//).Length
  • This 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.

    GetUri().Split(char[]//).[3].Split(char[]/;).[0]

    The agent returns create-user when it applies the getter chain to the following URL: http://HowdyWorld.example.com/create-user;sessionid=BE7F31CC0235C796BF8C6DF3766A1D00?act=Add&uid=c42ab7ad-48a7-4353-bb11-0dfeabb798b5

Split by Regular Expression

For more control, you can split values by string-based pattern matching. Pattern matching is particularly useful for situations that require complex matching, such as matching content within a request body.

The following example shows a getter chain that splits the value returned by GetAddress()

GetAddress().Split(string/\\W+).[6]

Given an address such as 303 2nd St, San Francisco, CA 94107 CA

Compose Getter Chains for HTTP Requests

The .NET Agent requires special syntax for getter chains for HTTP Requests:

Note: If you have both ASP.NET and ASP.NET Core on the full framework apps in the same tier, you cannot use a getter chain to apply to both because the two frameworks use different objects to handle HTTP requests.
  • Use the following syntax to delineate the boundaries of the getter chain:

    ${myobject.myproperty}
  • The following example determines the user principal:

    ${Context.User.Identity.Name}

Places to use this syntax include:

  • HTTP Request Data Collectors
  • ASP.NET Transaction Detection custom expressions