generated from pricelees/issue-pr-template
<!-- 제목 양식 --> <!-- [이슈번호] 작업 요약 (예시: [#10] Gitea 템플릿 생성) --> ## 📝 관련 이슈 및 PR **PR과 관련된 이슈 번호** - #28 ## ✨ 작업 내용 <!-- 어떤 작업을 했는지 알려주세요! --> - 프론트엔드, 백엔드 쿠버네티스 환경 배포(ArgoCD 이용) - Helm 차트는 private repository에 업로드 ## 🧪 테스트 <!-- 어떤 테스트를 생각했고 진행했는지 알려주세요! --> - 배포 환경에서 기능 정상 동작 확인 ## 📚 참고 자료 및 기타 <!-- 참고한 자료, 또는 논의할 사항이 있다면 알려주세요! --> Reviewed-on: #29 Co-authored-by: pricelees <priceelees@gmail.com> Co-committed-by: pricelees <priceelees@gmail.com>
50 lines
1.7 KiB
Kotlin
50 lines
1.7 KiB
Kotlin
package roomescape.common.log
|
|
|
|
import com.zaxxer.hikari.HikariDataSource
|
|
import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel
|
|
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder
|
|
import org.springframework.beans.factory.annotation.Qualifier
|
|
import org.springframework.boot.context.properties.ConfigurationProperties
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|
import org.springframework.boot.jdbc.DataSourceBuilder
|
|
import org.springframework.context.annotation.Bean
|
|
import org.springframework.context.annotation.Configuration
|
|
import org.springframework.context.annotation.Primary
|
|
import org.springframework.context.annotation.Profile
|
|
import javax.sql.DataSource
|
|
|
|
@Configuration
|
|
@Profile("deploy")
|
|
@EnableConfigurationProperties(SlowQueryProperties::class)
|
|
class ProxyDataSourceConfig {
|
|
|
|
@Bean
|
|
@Primary
|
|
fun dataSource(
|
|
@Qualifier("actualDataSource") actualDataSource: DataSource,
|
|
properties: SlowQueryProperties
|
|
): DataSource = ProxyDataSourceBuilder.create(actualDataSource)
|
|
.name(properties.loggerName)
|
|
.listener(
|
|
MDCAwareSlowQueryListenerWithoutParams(
|
|
logLevel = SLF4JLogLevel.nullSafeValueOf(properties.logLevel.uppercase()),
|
|
thresholdMs = properties.thresholdMs
|
|
)
|
|
)
|
|
.buildProxy()
|
|
|
|
@Bean
|
|
@ConfigurationProperties(prefix = "spring.datasource.hikari")
|
|
fun actualDataSource(): DataSource = DataSourceBuilder.create()
|
|
.type(HikariDataSource::class.java)
|
|
.build()
|
|
}
|
|
|
|
@Profile("deploy")
|
|
@ConfigurationProperties(prefix = "slow-query")
|
|
data class SlowQueryProperties(
|
|
val loggerName: String,
|
|
val logLevel: String,
|
|
val thresholdMs: Long,
|
|
)
|