add Sentry
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m53s
Publish Docker Image / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m7s

This commit is contained in:
Lee 2024-04-27 08:45:57 +01:00
parent 5332370c32
commit f2783d14da
3 changed files with 15 additions and 0 deletions

@ -73,6 +73,14 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Sentry -->
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter-jakarta</artifactId>
<version>7.8.0</version>
<scope>compile</scope>
</dependency>
<!-- Tests --> <!-- Tests -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

@ -2,6 +2,7 @@ package cc.fascinated.backend.exception;
import cc.fascinated.backend.model.response.ErrorResponse; import cc.fascinated.backend.model.response.ErrorResponse;
import io.micrometer.common.lang.NonNull; import io.micrometer.common.lang.NonNull;
import io.sentry.Sentry;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
@ -39,6 +40,7 @@ public final class ExceptionControllerAdvice {
} }
if (status == null) { // Fallback to 500 if (status == null) { // Fallback to 500
status = HttpStatus.INTERNAL_SERVER_ERROR; status = HttpStatus.INTERNAL_SERVER_ERROR;
Sentry.captureException(ex); // Capture the exception
} }
return new ResponseEntity<>(new ErrorResponse(status, message), status); return new ResponseEntity<>(new ErrorResponse(status, message), status);
} }

@ -19,6 +19,11 @@ spring:
database: test database: test
port: 27017 port: 27017
# Sentry Configuration
sentry:
dsn: ""
tracesSampleRate: 1.0
# Paste Configuration # Paste Configuration
paste: paste:
# The length of the ID for the paste # The length of the ID for the paste