In this tutorial, you use Wavefront for Spring Boot that uses Spring Boot 2 with the Spring petclinic sample application. This tutorial sets dependencies explicitly. In most cases, it makes sense to use the Spring Initializr instead to explore supported combinations.
Prerequisites
- Spring Boot 2.3.0 or above.
- Java 8 or above.
- Maven 3.3+ or Gradle 6.3 or later.
See System Requirements in the Spring Boot documentation. - Clone the sample petclinic application.
git clone https://github.com/spring-projects/spring-petclinic.git
- Build the project and start it.
cd spring-petclinic ./mvnw spring-boot:run
Send Data to Our Service
- Open the sample petclinic application using an IDE and add the following code to the
pom.xml
file:<dependency> <groupId>com.wavefront</groupId> <artifactId>wavefront-spring-boot-starter</artifactId> </dependency>
- Import the Wavefront for Spring Boot Bill of Materials (BOM) to your project. Add the following code to the
pom.xml
file (replace VERSION with the current version):Tip:Make sure the Wavefront for Spring Boot dependency is compatible with the Spring Boot release version. See System Requirements to get the correct dependency version.
For example, if you are using Spring Boot release version 2.5.3, theVERSION
needs to be 2.2.0.<dependencyManagement> <dependencies> <dependency> <groupId>com.wavefront</groupId> <artifactId>wavefront-spring-boot-bom</artifactId> <version>VERSION</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
- Add the following dependency to send trace data to our service using Spring Cloud Sleuth.
- Open your application and add the following code to your
pom.xml
file.<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency>
- Import the Spring Cloud Bill of Materials (BOM) to your project. Add the following code under
. Tip:Make sure the Spring Cloud dependency is compatible with the Spring Boot release version. See Getting Started on the Spring Cloud documentation for details.
For example, if you are using Spring Boot release version 2.5.3, theADD_VERSION
can be 2020.0.3.<dependencyManagement> <dependencies> ..... <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>{ADD_VERSION}</version> <type>pom</type> <scope>import</scope> </dependency> ..... </dependencies> </dependencyManagement>
- Open your application and add the following code to your
- Add the
P6Spy
dependency to intercept and log SQL queries. You can intercept most Connection, Statement and ResultSet methods invocations using the P6Spy dependency.Tip:See the P6Spy release notes and enter the latest version in place of
{ADD_VERSION}
.<dependency> <groupId>p6spy</groupId> <artifactId>p6spy</artifactId> <version>{ADD_VERSION}</version> <scope>runtime</scope> </dependency>
- Add the following configurations to the
application.properties
file so that your application is namedspring-demo
, and the service is namedspring-petclinic
.wavefront.application.name=spring-demo wavefront.application.service=spring-petclinic spring.sleuth.jdbc.p6spy.enable-logging=true
-
To send data to your Operations for Applications account, specify the
uri
andapi-token
properties as follows:management.wavefront.api-token=$API_Token management.wavefront.uri=$wavefront_instance
$API_Token
is a valid API token for your Operations for Applications instance.$wavefront_instance
is the name of your Operations for Applications instance, for example,https://example.wavefront.com
.
- Restart the application and navigate to http://localhost:8080.
- Add data from the petclinic user interface.
For example:
- Add an Owner and a Pet via the User Interface.
- Click ERROR to trigger errors.
Examine Inventory Data
To examine the data:
- Go to your server instance, click Dashboards > All Dashboards and enter
Spring Boot Inventory
. - Select Contains: Spring Boot Inventory, and click the Spring Boot Inventory result in the table.
You are taken to the Wavefront Spring Boot Inventory dashboard where you can examine the data sent by your application. This dashboard provides real-time visibility into your Spring Boot application landscape. The dashboard has several sections that include the following charts:
- Status of hosts, applications, and services.
- Request rate
- Inventory details
- Hosts. Use the drop-down menus to group the hosts.
If one or more applications are enabled for tracing, click the link in the Tracing section to be directed to the Tracing dashboard.
Examine RED Metrics and Traces
When you click the link in the Spring Boot Inventory dashboard, you are taken to the Spring Boot Traces Browser where you can:
- View the trace data of the
spring-petclinic
service.- Once in the Traces Browser, you see the traces from the application and the trace related to the error you created.
- If you configured your application to send trace data using OpenTracing, you can see span logs for the errors you triggered.
- View details specific to an application service, such as the Request, Error, and Duration (RED) metrics by clicking on the Traces Browser. See Explore the Default Service Dashboard for details.
Note:
When your application sends data for the first time, they appear after about 1 minute. If you see data from the beachshirts sample application, refresh the page or go to Application > Application status to view the status of your application.
Next Steps
- See the Wavefront for Spring Boot FAQs.
- You cannot save changes that you make to the preconfigured Spring Boot Inventory and Wavefront for Spring Boot Service Dashboards. If you want custom dashboards, you must clone and edit the dashboard. For details, see Create and Customize Dashboards.
- Customers can create smart alerts that dynamically filter noise and find true anomalies. For details, see Alerts.