Configure Wavefront for Spring Boot with a sample application.

In this tutorial, you use Wavefront for Spring Boot with the Spring pet clinic sample application. Let’s get started!

Video

Let’s take a look at how you can configure your Spring Boot application with Wavefront for Spring Boot to send data to Wavefront and analyze this data.

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 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

  1. Open the sample pet clinic application using an IDE and add the following code:
     <dependency>
       <groupId>com.wavefront</groupId>
       <artifactId>wavefront-spring-boot-starter</artifactId>
       <version>2.0.0</version>
     </dependency>
    
  2. Add the following dependency to send trace data to Wavefront using Spring Cloud Sleuth or OpenTracing.

    Maven:
    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>
      <version>2.2.2.RELEASE</version>
    </dependency>
             

    Maven:
    Open your application and add the following code to your pom.xml file.

    <dependency>
      <groupId>io.opentracing.contrib</groupId>
      <artifactId>opentracing-spring-cloud-starter</artifactId>
      <version>0.5.3</version>
    </dependency>
         
  3. Add the following configurations to the application.properties file so that your application is named spring-demo, and the service is named spring-petclinic.
     wavefront.application.name=spring-demo
     wavefront.application.service=spring-petclinic
    
  4. Restart the application and navigate to http://localhost:8080.
  5. Add data by clicking on the pet clinic user interface. For example:
    1. Add an Owner and a Pet via the User Interface.
    2. Click ERROR to trigger errors.
  6. Click the one-time use link to access the Wavefront Service dashboard and view data.

    Example:

     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 RED Metrics and Traces

When you click the link, you are taken to the Services dashboard where you can:

  • View details specific to an application service, such as the Request, Error, and Duration (RED) metrics. See Explore the Default Service Dashboard for details.

    Wavefront Service dashboard

  • Click See All spring-petclinic Traces to navigate to the Tracing browser and view the trace data of the spring-petclinic service.
    • Once in the tracing 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. Span logs for the pet clinic applciation

Next Steps