Skip to content

Commit

Permalink
Feat: 운영 환경 Sentry 도입
Browse files Browse the repository at this point in the history
  • Loading branch information
suminnnnn committed Sep 25, 2024
1 parent b7281eb commit ecde315
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ dependencies {

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'

implementation 'io.sentry:sentry-spring-boot-starter-jakarta:7.14.0'

developmentOnly("org.springframework.boot:spring-boot-docker-compose")
testAndDevelopmentOnly("org.springframework.boot:spring-boot-docker-compose")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmc.blink.global.exception.handler;

import cmc.blink.global.exception.dto.ApiErrorResponse;
import io.sentry.Sentry;
import cmc.blink.global.exception.GeneralException;
import cmc.blink.global.exception.JwtAuthenticationException;
import cmc.blink.global.exception.constant.ErrorCode;
Expand All @@ -21,27 +22,32 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(
MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) {
Sentry.captureException(ex);
return handleExceptionInternalFalse(ex, ErrorCode.INVALID_DATA, headers, status, request);
}

@org.springframework.web.bind.annotation.ExceptionHandler
public ResponseEntity<Object> handleConstraintViolationException(ConstraintViolationException e, WebRequest request) {
Sentry.captureException(e);
return handleExceptionInternal(e, ErrorCode.UNAUTHORIZED, request);
}

@org.springframework.web.bind.annotation.ExceptionHandler
public ResponseEntity<Object> handleGeneralException(GeneralException e, WebRequest request) {
Sentry.captureException(e);
return handleExceptionInternal(e, e.getErrorCode(), request);
}

@org.springframework.web.bind.annotation.ExceptionHandler
public ResponseEntity<Object> exception (Exception e, WebRequest request) {
e.printStackTrace();
Sentry.captureException(e);
return handleExceptionInternalFalse(e, ErrorCode.INTERNAL_ERROR, HttpHeaders.EMPTY, ErrorCode.INTERNAL_ERROR.getHttpStatus(), request);
}

@org.springframework.web.bind.annotation.ExceptionHandler(JwtAuthenticationException.class)
public ResponseEntity<Object> handleJwtAuthenticationException(JwtAuthenticationException e, WebRequest request) {
Sentry.captureException(e);
return handleExceptionInternal(e, ErrorCode.UNAUTHORIZED, request);
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ spring:
port: ${AWS_REDIS_PORT}
docker:
compose:
enabled: false
enabled: false

sentry:
dsn:
enable-tracing: false
environment: dev
7 changes: 6 additions & 1 deletion src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ spring:
port: 6379
docker:
compose:
enabled: true
enabled: true

sentry:
dsn:
enable-tracing: false
environment: local
9 changes: 7 additions & 2 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spring:
password: ${AWS_DB_PASSWORD}
jpa:
hibernate:
ddl-auto: update
ddl-auto: none
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
Expand All @@ -16,4 +16,9 @@ spring:
port: ${AWS_REDIS_PORT}
docker:
compose:
enabled: false
enabled: false

sentry:
dsn: ${SENTRY_DSN}
enable-tracing: true
environment: prod

0 comments on commit ecde315

Please sign in to comment.