In this tutorial, you use Wavefront for Spring Boot with the Spring pet clinic sample application. This tutorial sets dependencies explicitly. In most cases, it makes sense to use the Spring Initializr instead to explore supported combinations.
- Spring Boot 2.3.0 or above.
Note: This tutorial uses Spring Boot 2.3.4.
- Java 8 or above.
- Maven 3.3+ or Gradle 6.3 or later.
See System Requirements in the Spring Boot documentation.
- Clone the sample pet clinic 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 Wavefront
- Open the sample pet clinic application using an IDE and add the following code to the
<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.xmlfile (replace VERSION with the current version):Tip:
Spring Boot version 2.3.4 is used for this tutorial. If you are using another version 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.
<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 Wavefront using Spring Cloud Sleuth or OpenTracing. Pick either Spring Cloud Sleuth or OpenTracing and use it across all your microservices.
Open your application and add the following code to your
<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 <dependencyManagement>.Tip:
Spring Boot version 2.3.4 is used for this tutorial. If you are using another version make sure the Spring Cloud dependency is compatible with the Spring Boot release version. See Getting Started on the Spring Cloud documentation for details.
<dependencyManagement> <dependencies> ..... <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Hoxton.SR8</version> <type>pom</type> <scope>import</scope> </dependency> ..... </dependencies> </dependencyManagement>
Open your application and add the following code to your
<dependency> <groupId>io.opentracing.contrib</groupId> <artifactId>opentracing-spring-cloud-starter</artifactId> <version>0.5.7</version> </dependency>
- Add the following configurations to the
application.propertiesfile so that your application is named
spring-demo, and the service is named
- Restart the application and navigate to http://localhost:8080.
- Add data by clicking on the pet clinic user interface.
- Add an Owner and a Pet via the User Interface.
- Click ERROR to trigger errors.
- Click the one-time use link to access the Wavefront Service Dashboard and view data.
Tip: Make sure to save the one-time use link so you can access the same dashboard each time you restart your application.
To share this account, make sure the following is added to your configuration: management.metrics.export.wavefront.api-token=44444-34this-45is-123a-sampletoken management.metrics.export.wavefront.uri=https://wavefront.surf Connect to your Wavefront dashboard using this one-time use link: https://wavefront.surf/us/example
Examine Inventory Data
When you click the link in the Wavefront Spring Boot starter, you are taken to the Spring Boot Inventory dashboard. 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 pulldown 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
- 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.
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.
- See the Wavefront for Spring Boot FAQs.
- You cannot save changes that you make to the preconfigured Spring Boot Inventory and Wavefront Service Dashboards. If you want custom dashboards, clone and edit it the Wavefront dashboard. For details, see Create and Customize Dashboards.
- Wavefront customers or trial users can create smart alerts that dynamically filter noise and find true anomalies. For details, see Alerts.
Note: Alerts are not supported on this freemium cluster.
- Try out the pet clinic application with the Micrometer. See Wavefront for Spring Boot: Getting Started for details.