@Trace Annotation for Stackify Java APM+
Stackify APM+ Overview:
http://support.stackify.com/agent-installation-overview/
Sign Up for a Trial:
http://www.stackify.com/sign-up/
Add it as a maven dependency:
<dependency>
<groupId>com.stackify</groupId>
<artifactId>stackify-java-apm-annot</artifactId>
<version>INSERT_LATEST_MAVEN_CENTRAL_VERSION</version>
</dependency>
Real User Monitoring (RUM) manual instrumentation allows you to specify where the RUM JavaScript block is injected.
It is recommended you provide a stackify-api.properties
file in your application classpath with the following content:
stackify.application=My Application Name
stackify.environment=My Environment Name
Your application code will need to call out to the Stackify com.stackify.apm.Stackify.getRUMJavaScriptBlock()
method in the <head>
section as detailed below:
JSP Example
<html>
<head>
<%= com.stackify.apm.Stackify.getRUMJavaScriptBlock() %>
<script and link tags>
</head>
<body>
...
</body>
</html>
Add custom instrumentation to classes using the @Trace annotation. The annotation needs to be added to the class and the method to be instrumented. This is an alternative to adding a custom configuration file (stackify-apm.json) to your application.
- 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 anint
referencing the parameter index on the annotated method, index starts at 0).
Stackify by default generates traces from web-requests on supported application servers
and non-web-requests from supported frameworks.
You can extend support by using @Trace(start = true)
on a method; which will start a new trace.
import com.stackify.apm.Trace;
@Trace
public class ClassToBeInstrumented
{
@Trace(start = true)
public void methodToStartNewTrace()
{
...
}
@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()
{
...
}
}
Copyright 2017 Stackify, LLC.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.