AllStack Docs
  • Welcome
  • Getting Started
    • Laravel SDK
    • Node.js SDK
  • Spring Boot SDK
  • ReactJS SDK
  • Real-Time Server Monitoring
  • Flutter SDK
  • 📈 Stress Test Your App
Powered by GitBook
On this page
  • AllStak Spring Boot SDK Installation Guide
  • Step 1: Add the AllStak Dependency
  • Step 2: Configure AllStak Properties
  • Step 3: Capture Exceptions with AllStak
  • Step 4: Enable Global Exception Handling (Optional)
  • Additional Notes

Spring Boot SDK

AllStak Spring Boot SDK Installation Guide

Step 1: Add the AllStak Dependency

To integrate AllStak with your Spring Boot application, add the following dependency to your pom.xml:

<dependency>
    <groupId>io.allstak</groupId>
    <artifactId>allstak-springboot</artifactId>
    <version>1.0.4</version>
</dependency>

For Gradle users, add this to build.gradle:

dependencies {
    implementation 'io.allstak:allstak-springboot:1.0.4'
}

Step 2: Configure AllStak Properties

Add the following properties to your application.properties or application.yml file:

For application.properties:

allstak.api-key=your-api-key
allstak.environment=dev
allstak.release=1.0.0

For application.yml:

allstak:
  api-key: your-api-key
  environment: dev
  release: 1.0.0

Step 3: Capture Exceptions with AllStak

To automatically capture exceptions, add the following snippet inside a try-catch block:

try {
    // Your application logic here
} catch (Exception e) {
    AllStak.captureException(e);
}

This ensures that all unhandled exceptions are logged and sent to AllStak for monitoring.

Step 4: Enable Global Exception Handling (Optional)

To globally capture exceptions in your Spring Boot application, you can use @ControllerAdvice as follows:

import io.allstak.AllStak;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public String handleException(Exception e) {
        AllStak.captureException(e);
        return "An error occurred. The issue has been logged.";
    }
}

This setup ensures that all exceptions in your application are automatically sent to AllStak for tracking and debugging.


Additional Notes

  • Ensure that your API key is kept secure and not exposed in public repositories.

  • The allstak.environment property allows you to specify different environments (e.g., dev, staging, prod).

  • The allstak.release property helps track issues across different application versions.

By following these steps, you will have successfully integrated AllStak with your Spring Boot application for enhanced error monitoring and tracking.

PreviousNode.js SDKNextReactJS SDK

Last updated 3 months ago