Function/Method Sensor Rules

PHP Function/Method rules define functions or methods to be instrumented. A Function/Method Rule is always a child of a Path Rule, and instruments only functions/methods from files, defined by the parent Path Rule.

Unlike sensor rules for Java or .NET, PHP sensor rules have only one placement option — include, which means functions/methods affected by this rule should be instrumented.

Function/Method rule properties
Function/Method rule properties

Configure a Function/Method Rule in the PHP Function/Method Rule Properties dialog box:

  • While creating a new Function/Method Rule:
    1. Open the System Profile Preferences dialog box, and select the Sensor item.
    2. Select the required Sensor Group.
    3. Select the required Path Rule, or create a new one and then select it. See Path Rule to learn how.
    4. Click Add Function/Method.
  • While editing an existing Function/Method Rule:
    1. Open the System Profile Preferences dialog box, and select the Sensor item.
    2. Select the required Sensor Group.
    3. Expand a Path Rule, select the required Function/Method Rule, and then click Edit.

Pattern

Function/Method Rules do not necessarily specify concrete names of functions, or classes and methods. Instead they use patterns. These patterns can be specified using one of the following modes:

  • equals: The pattern applies if the actual name is equal to the pattern text.
  • starts: The pattern applies if the actual name starts with the given pattern text.
  • ends: The pattern applies if the actual name ends with the given pattern text.
Note

An empty pattern affects all functions/classes/methods.

General

Type: The type of the Rule.

  • Function: Instruments PHP functions, matching the pattern.
  • Method: Instruments PHP methods, matching pattern in the Method field. Only methods from classes, matching the Class pattern, are instrumented.

Function, Class, Method: The string pattern used to match names of actual functions, classes, and methods. See the Patten section above.

Capture arguments: The arguments to be captured. Arguments are captured by their position starting with 1. Use asterisk (*) to capture all arguments.

Options

Capture Events: Toggle the capturing state of methods instrumented due to this rule. If event capturing is disabled, the Sensors placed due to this rule are disabled. You can change the capturing during runtime.

This method rule denots an External API Service call: Mark invocations of this method as External API Service calls.

Optionally you can specify service and instance name for this External API Service call. The instance name will fall back to the method name. It is possible to specify patterns of the form '{X}', where X is the Xth captured argument. Note, that 0 being reserved for the return value. Special placeholders '{method}' and '{service}' will evaluate to method name or service name, respectively.

Method return values are recorded: Records and shows the return value in the corresponding PurePath every time a matching method is called.

Rule execution order

More restrictive rules have the priority over less restrictive rules.