The Target probe object

The Target probe object is a specification of the classes and methods to which the probe should be applied.

The Target object is optional. When no Target is specified, the probe will be applied to all classes that are processed by the instrumentation engine.

The Target object lets you create filter rules to include or exclude methods from instrumentation based upon patterns that are matched against the package, class, and method name, plus the method's signature. The patterns can contain wildcards, where "*" will match zero or more characters.

If a Target's wildcard patterns match a method's package, class, name and signature, the type property determines whether the method is instrumented (include) or not (exclude). If the patterns do not match a method's package, class, name and signature, by default, the method is instrumented.

The Target object includes the following properties:
Property Description
type Required. The type property determines whether or not a probe is applied to a target method. Specify include to apply the probe to classes and methods that match the wildcard patterns, exclude to exclude them.
package Optional. Specify a wildcard pattern to match against the package portion of class names. For example: java.util* will match every class in the java.util package and its subpackages. If not specified, the default value is *.
className Optional. Specify a wildcard pattern to match against class names. If not specified, the default value is *.
method Optional. Specify a wildcard pattern to match against method names. If not specified, the default value is *.
signature Optional. Specify a wildcard pattern to match against a method's signature - that is, the string representing the method's arguments and return type. This is in the Java internal format for method signatures. For example: (Ljava/lang/Object;)D is the signature of a method that takes an Object as a parameter and returns a double. This wildcard pattern can be used to distinguish among overloaded methods. If not specified, the default value is *.

Notes:

  • A probe can have multiple Target objects containing successive targeting rules. To target only the methods you specify, add a final Target object that specifies package=* className=* method=* signature=* type=exclude after the Target object for the methods you want to target.
  • Package and class names specified in a Target object are also checked against the package and class names of any interfaces that a class implements. For example, java.util.HashMap implements the interface java.util.Map. If a probe targets the package java.util, the class name Map, and the method name size, the probe will be applied to java.util.HashMap.size(), and to the size method of any other class that implements the Map interface.
  • Pattern matching does not consider inheritance relationships: if class Derived extends class Base, and a probe targets Base.run(), the probe will not automatically be applied to Derived.run().
  • If the package pattern in a Target object is a single period character ("."), it represents the global, unnamed Java package. This lets you explicitly target classes in the global package. For example:
    <target type="include" package="." class="SomeClass" method="*" />
    <target type="exclude" package="*" class="*" method="*" />
    These two target rules cause the probe to target the class SomeClass in the global package, while excluding all other classes. By these rules, a class called SomeClass that is in any other package is excluded.
  • Callsite probes match target patterns and rules against the package, class, name and signature of a called method. The matching is done against the called method as it was known at compile time; that is, against the statically-known class and method names, not the actual methods that will be called due to inheritance and virtual functions. If the call is done through an interface reference, the interface name must match.
Example
<target
  type="include"
  package="com.example"
  className="*Proxy"
  method="Get*"
/>

Contained by
The Probe object

Parent topic: Probekit element reference

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.