Quickly add data-tracking metrics to SparkJava responses without modifying any code
SJIA is a Java Agent that allows for instantaneous metric monitoring without adding any code in your project. Responses are modified with headers that indicate metrics such as round trip time. SJIA also includes an optional built-in monitoring application that allows you to see live updates of the performance of your SparkJava routes.
Download a release package of SJIA, unzip/untar and execute your application with the javaagent jvm flag set to point to the SJIA jar executable.
java -javagent:sjia.jar -jar application.jar
java -javagent:sjia.jar=monitor -jar application.jar
The monitoring application will open a web server on port 45000. The latest statistics can be retrieved by issuing a GET command to http://localhost:45000/stats. Doing so will retrieve a JSON object structured like:
{
"*": {
"max": 51.0,
"min": 50.0,
"avg": 50.2
},
"/metrix": {
"max": 51.0,
"min": 50.0,
"avg": 50.2
}
}
Visiting the address http://localhost:45000 in a web browser will open the the metric monitoring utility.
Metrics in the form of HTTP Response Headers are added to every route.
Header | Description |
---|---|
X-metric-time-min | Minimum Response Time |
X-metric-time-max | Maximum Response Time |
X-metric-time-avg | Mean Response Time |
X-metric-time | Response Time |
X-metric-body-min | Minimum Response Body Size |
X-metric-body-max | Maximum Response Body Size |
X-metric-body-mvg | Mean Response Body Size |
X-metric-body | Response Body Size (bytes) |
Download the release file, unzip the sjia.jar and example.jar. Execute the following command:
java -javagent:sjia.jar=monitor -jar example.jar
The example webapp is accessible via http://localhost:4567, and the SJIA monitoring application is accessible via http://localhost:45000.
git clone https://github.com/argonotix/sjia.git
cd sjia
chmod +x ./gradlew
./gradlew build shadowJar
cp ./agent/build/libs/agent-0.1-all.jar ./sjia.jar
Distributed under the MIT license.