Custom Profiling: Configure for Java

The custom configuration file needs to be named ‘stackify-apm.json’ and be located in the classpath. You can configure additional classes and methods that you want to instrument.

Example:

[{

    "Class": "com.stackify.example.util.ClassToBeInstrumented",

    "Method": "methodToBeInstrumented"

},

{

    "Class": "com.stackify.example.util.ClassToBeInstrumented",

    "Method": "anotherMethodToBeInstrumented"

}]

You can also add custom instrumentation to classes by using @Trace Annotation. See more information on our Github page here:

https://github.com/stackify/stackify-java-apm-annot

Once the configuration has been saved, please restart the Web container.

Tracked Functions

  • trackedFunction marks a specific method as a tracked function.
  • trackedFunctionName gives control over how the tracked function will be identified in the dashboard. The function name can be a String and can also include the variables {{ClassName}}, {{MethodName}} and {{MethodParameters[#]}}(where # is an int referencing the parameter index on the annotated method, index starts at 0).
import com.stackify.apm.Trace;

@Trace
public class ClassToBeInstrumented 
{
    @Trace
    public void methodToBeInstrumented()
    {
        ...
    }

    @Trace
    public void anotherMethodToBeInstrumented()
    {
        ...
    }

    @Trace(trackedFunction = true, trackedFunctionName = "Tracked Function Identifier")
    public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunction()
    {
        ...
    }

    @Trace(trackedFunction = true, trackedFunctionName = "Tracked Function {{ClassName}} - {{MethodParameters[0]}}")
    public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunctionVariable(String value)
    {
        ...
    }

    public void notInstrumented()
    {
        ...
    }
}

Custom Trace Entry Point

Retrace by default generates traces from web-requests on supported application servers and non-web-requests from supported frameworks (Retrace: Supported Java Application Containers and Frameworks).

You can extend support by using @Trace(start = true) on a method; which will start a new trace.

{
    "Class": "com.stackify.example.util.ClassToBeInstrumented",
    "Method": "methodToBeInstrumented",
    "StartTrace": true
},
{
    "Class": "com.stackify.example.util.ClassToBeInstrumented",
    "Method": "methodToBeInstrumented"
}

JSON Configuration:

{
    "Class": "com.company.SampleController",
    "Method": "testMethod",
    "TrackedFunction": true,
    "TrackedFunctionName": "Tracked Function Test {{ClassName}}.{{MethodName}}"
}