- 2 Minutes to read
- Print
- DarkLight
- PDF
Spring PetClinic as a Stand-alone App
- 2 Minutes to read
- Print
- DarkLight
- PDF
This guide describes how to enable the Retrace Java profiler on a stand-alone Spring PetClinic application.
The app has the following pages:
- Home - a simple landing page
- Find Owners - page showcasing simple DB queries as part of sub-transactions that add a new owner and find records.
- Veterinarians - page that shows the list of vets in tabular format
- Error - used to simulate an exception. The exception will be auto-captured by the profiler and then reported to your Retrace account.
More information about the PetClinic app can be found at https://spring-petclinic.github.io/.
Pre-requisites
- Retrace agent. Your machine will appear on your Retrace account after installing the agent.
- Java (either JRE or JDK will work)
Download the appropriate package for your environment at https://jdk.java.net/21/
Extract the contents of archive and take note of the path.
- On Windows:
- On Windows:
Add the system variables:
JAVA_HOME=/Path/To/Your/JavaDir
andPath=${existing path values};/Path/To/Your/JavaDir/bin
- On Windows:
NoteThe app used in this guide does not require the JRE_HOME variable so the variable seen in the screenshot can be disregarded. Other apps, however, might require this variable.
- On Linux:
$ export JAVA_HOME=/Path/To/Your/JavaDir $ export PATH=${PATH}:/Path/To/You/JavaDir
- On Windows:
Test by opening the terminal and executing the command
java -version
.
Now that both the Retrace agent and Java are installed, let's proceed to the next section.
Enabling APM on the Java App
Download the sample app from the GitHub repo and save to your preferred location: https://github.com/stackify/example-apps/raw/main/sample-java-petclinic/spring-petclinic-2.7.0.jar.
Clicking on the click will trigger the download of a jar file.Open the terminal and go to the same directory you saved the app (jar file) in Step 1, and then run the app using the Java command:
- On Windows
C:\your-app-path> java -Djava.io.tmpdir="C:\your-app-path\" -Dserver.port=<any-unused-port> -javaagent:"C:\ProgramData\Stackify\Profiler\Java\stackify-java-apm.jar" -DSTACKIFY_APPLICATION_NAME="Your-App-Name" -DSTACKIFY_ENVIRONMENT_NAME="Your-Env-Name" -jar spring-petclinic-2.7.0.jar
Image showing the app's path/location:
Image showing a successful launch of the app:
- On Linux:
$ java -Dserver.port=<any-unused-port> -javaagent:/usr/local/stackify/stackify-java-apm/stackify-java-apm.jar -DSTACKIFY_APPLICATION_NAME="Your-App-Name" -DSTACKIFY_ENVIRONMENT_NAME="Your-Env-Name" -jar spring-petclinic-2.7.0.jar
Image showing the app location on Linux:
Image showing a successful start of the app on Linux:
To check port availability, open your browser and go to http://localhost:<port-number>, e.g. http://localhost:80. If a web page loads (i.e. no errors such as "localhost refused to connect/the site can't be reached"), then the port is already in use and you may need to choose a different port.
Send requests to the app and view APM data in Retrace.
To view the app, open your browser and go to http://localhost:[port-used-in-step-2].Here's what the landing page looks like:
And how APM will appear in Retrace:
Post-Installation Checks
The Retrace Java profiler will generate output logs at
C:\ProgramData\Stackify\Java\
, in.\debug
for debug logs and.\log
for trace logs after the app receives any request. In Linux, the paths are at/usr/local/stackify/stackify-java-apm/debug
and/usr/local/stackify/stackify-java-apm/log
As long as traces are generated, it should only be a matter of time before the app appears in your Retrace account.
Done!
To learn more about viewing your application's data, be sure to check out documentation on the App Dashboard.