Java
Spring Boot

Spring Boot Web Application

On this page, we help you install ShortLoop Java SDK in your Spring Boot web application, so that it can automatically sample traffic.

Install

Add ShortLoop Java SDK as a Maven or Gradle dependency

<dependency>
  <groupId>dev.shortloop.agent</groupId>
  <artifactId>agent-java</artifactId>
  <version>0.0.12</version>
</dependency>

Configure

Add the following in your application's application.properties or application.yaml configuration file.

shortloop.enabled=true
shortloop.applicationName=service-name                 # your application name here
shortloop.environment=env-name                         # your application environment (Eg. stage, prod, alpha, etc.)
shortloop.url=https://shortloop.company-name.com       # the shortloop url for your org. (Provided by ShortLoop team.)
shortloop.authKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # shortloop Auth Key. (Provided by ShortLoop team.)
shortloop.maskHeaders=cookie,x-auth                    # [Optional]. The following headers values will be masked at the SDK level itself. (Will not be sent to the server)

Register SDK with Spring by adding the following piece of code on top of your application's entry class.

import dev.shortloop.agent.ShortloopAutoConfiguration;
@Import(ShortloopAutoConfiguration.class)

After adding the above, your application's entry class file (ex: Application.java) should look something like this:

... 
import dev.shortloop.agent.ShortloopAutoConfiguration;
...
...
 
...
@Import(ShortloopAutoConfiguration.class)
public class Application {
  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
    ...
  }
}
 

Verify

Quickly test if project is building after configuring SDK.

⚠️

Build command maybe custom to your project.

mvn clean install

After the changes, redeploy your Spring Application.

Feel free to email for a quick support, reporting bug or improvements suggestions. Sumit B Mulchandani (sumit@shortloop.dev)

Copyright © 2023 ShortLoop, Inc. All rights reserved.