Fully featured low overhead profiler for Java EE and Java SE platforms.
Monitoring and profiling solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Probe class annotation @MethodPattern

Probe class must be annotated with @MethodPattern annotation in order to specify which methods the callbacks will be applied to.

One or more method patterns can be specified in the following format ('*' wildcard is allowed):

class_name : method_name ( parameter_types )

You can optionally specify that class or method must have particular annotations. Put @annotation before the class and/or the method pattern accordingly:

[@class_annotation] class_name : [@method_annotation] method_name ( parameter_types )

Part Description Examples
class_name Full qualified class name, dot-separated. Inner class part(s) are separated with "$" sign.

Particular class: com.foo.Bar

Class with name ending with 'Helper': *Helper

Any class in a package: java.io.*

Any class: *

class_annotation (optional) Specify that matching classes must have particular annotation. If not specified, class with any annotations or with no annotations at all will match.

All toString methods in classes in package com.bar annotated with @Foo:
@Foo com.bar.* : toString()

method_name Method name. To specify a constructor, use <init>.

Method with particular name: toString

Any getter: get*

Any method, including constructors: *

method_annotation (optional) Specify that matching methods must have particular annotation. If not specified, methods with any annotations or with no annotations at all will match.

All JUnit tests: *:@org.junit.Test *()


Comma-separated list of parameter types. Space characters between type names and commas are allowed (but not required).

Class names should be full qualified, dot-separated, except for java.lang.Object, java.lang.Object[], java.lang.String, java.lang.String[] for which a short form is allowed: Object, Object[], String, String[].

Primitive types should be named as in Java source code: int, char etc.

Arrays are specified as <type>[].

Use empty string to specify a method with no parameters.

No parameters: empty

Any number of parameters, including zero: *

3 parameters of particular types: String, int, int

First parameter is an array of class com.Foo: com.Foo[], *

The annotation is declared as...

package com.yourkit.probes;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

public @interface MethodPattern {
  String[] value();

...and specifies one or more patterns for a probe. For example:

import com.yourkit.probes.*;

// Instrument calls of method 'findPerson' in class 'com.foo.Person', which has 2 parameters of particular types
@MethodPattern("com.foo.Person:findPerson(String, int)")
public class MyProbe1 {

// Instrument all methods in classes 'com.Foo' and 'com.Bar'
    // should match at least one of them
public class MyProbe2 {

// Instrument methods toString() in all classes in package com.foo
public class MyProbe3 {

// Instrument all methods in classes whose names end with 'Helper' and have int[][] as a first parameter
public class MyProbe4 {