Skip to content

Commit

Permalink
[BSVR-154] sentry 설정 (#76)
Browse files Browse the repository at this point in the history
* build: sentry dependency 추가

* build: sentry dependency 추가

* feat: sentry 설정 추가

* feat: captureException 테스트용 코드 추가

* feat: add application-sentry on gitignore

* feat: sentry profile 추가

* feat: delete sentry yml

* build: spring profile 환경별로 분리

* build: sentry 설정 수정

* fix: jpa 설정 원복

* feat: sentry 테스트용 코드 삭제

* feat: logback-spring 추가

* build: 불필요한 설정 제거

* build: 불필요한 설정 제거

* build: profile별로 swagger, p6spy 설정 분기

* fix: swagger enabled 설정 수정

* fix: p6spy enabled 설정 수정

* fext: 불필요한 설정 삭제

* feat: 불필요한 설정 삭제

* feat: prod에서 swagger enabled false

* feat: spring.profile.active=local

* feat: dev-build-and-deploy.yaml 프로필 prod 설정 추가

* feat: dev-build-and-deploy.yaml에 application-sentry 설정 주입

---------

Co-authored-by: Minseong Park <pminsung12@gmail.com>
  • Loading branch information
EunjiShin and pminsung12 authored Jul 26, 2024
1 parent d282cb0 commit f424626
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 32 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/dev-build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
docker rm spot-server-dev || true
docker run -d --name spot-server-dev \
-p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=prod \
-e SPRING_DATASOURCE_URL=${{ secrets.DEV_DB_URL }} \
-e SPRING_DATASOURCE_USERNAME=${{ secrets.DEV_DB_USERNAME }} \
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} \
Expand All @@ -119,6 +120,9 @@ jobs:
-e NCP_OBJECT_STORAGE_ACCESS_KEY=${{ secrets.NCP_OBJECT_STORAGE_ACCESS_KEY }} \
-e NCP_OBJECT_STORAGE_SECRET_KEY=${{ secrets.NCP_OBJECT_STORAGE_SECRET_KEY }} \
-e TZ=Asia/Seoul \
-e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-e SENTRY_ENABLE_TRACING=true \
-e SENTRY_ENVIRONMENT=prod \
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }}
docker system prune -af
Expand Down
13 changes: 13 additions & 0 deletions application/src/main/resources/appenders/console-appender.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<included>
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%highlight([%-5level]) %d{yy-MM-dd HH:mm:ss.SSS} %green([%thread]) %cyan([%logger{0}:%line])-%message%n
</pattern>
</encoder>
</appender>

<appender name="SENTRY_APPENDER" class="io.sentry.logback.SentryAppender">
<minimumEventLevel>ERROR</minimumEventLevel>
</appender>
</included>
74 changes: 58 additions & 16 deletions application/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,63 @@
server:
port: 8080
shutdown: graceful
port: 8080
shutdown: graceful

spring:
# 서브모듈 profile
profiles:
include:
- jpa
- ncp
- jwt
- kakao
# swagger를 이용해 API 명세서 생성
doc:
# 서브모듈 profile
profiles:
active: local
group:
local:
- jpa
- ncp
- jwt
- kakao
dev:
- jpa
- ncp
- jwt
- kakao
prod:
- jpa
- ncp
- jwt
- kakao
- sentry
servlet:
multipart:
max-file-size: 10MB
max-request-size: 30MB

springdoc:
swagger-ui:
path: /swagger-ui.html
enabled: true
path: /swagger-ui.html

decorator:
datasource:
p6spy:
enable-logging: true
---
spring:
config:
activate:
on-profile: local
---
spring:
config:
activate:
on-profile: dev
---
spring:
config:
activate:
on-profile: prod

decorator:
datasource:
p6spy:
enable-logging: false

servlet:
multipart:
max-file-size: 10MB
max-request-size: 30MB
springdoc:
swagger-ui:
enabled: false
23 changes: 23 additions & 0 deletions application/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds">
<include resource="appenders/console-appender.xml"/>

<springProfile name="local">
<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER"/>
</root>
</springProfile>

<springProfile name="dev">
<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER"/>
</root>
</springProfile>

<springProfile name="prod">
<root level="ERROR">
<appender-ref ref="CONSOLE_APPENDER"/>
<appender-ref ref="SENTRY_APPENDER"/>
</root>
</springProfile>
</configuration>
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
plugins {
id("java")
id("io.sentry.jvm.gradle")
id("com.diffplug.spotless")
id("org.springframework.boot")
id("io.spring.dependency-management")
id("com.diffplug.spotless")
}

allprojects {
Expand All @@ -20,6 +21,7 @@ subprojects {
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "io.sentry.jvm.gradle")

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down
3 changes: 3 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")

// sentry
implementation("io.sentry:sentry-logback:_")
}

tasks.jar { enabled = true }
Expand Down
15 changes: 1 addition & 14 deletions infrastructure/jpa/src/main/resources/application-jpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,4 @@ spring:


server:
port: 8080

logging:
level:
org.depromeet.spot: DEBUG
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE

decorator:
datasource:
p6spy:
enable-logging: true

# 필요한 경우 추가 설정
port: 8080
8 changes: 7 additions & 1 deletion versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

plugin.org.springframework.boot=3.0.1

plugin.io.sentry.jvm.gradle=4.10.0

plugin.io.spring.dependency-management=1.0.11.RELEASE

plugin.com.diffplug.spotless=6.21.0
Expand All @@ -33,4 +35,8 @@ version.com.querydsl..querydsl-jpa=5.0.0

version.org.springframework.cloud..spring-cloud-starter-aws=2.2.6.RELEASE

version.org.springframework.boot..spring-boot-configuration-processor=3.0.1
version.org.springframework.boot..spring-boot-configuration-processor=3.0.1

version.io.sentry..sentry-logback=7.12.0

version.io.sentry..sentry-spring-boot-starter-jakarta=7.12.0

0 comments on commit f424626

Please sign in to comment.