히카리 (1)
히카리 풀 모니터링

히카리 풀을 사용하게 되면 housekeeper란 놈이 기본으로 30초마다 풀 상태를 debug모드로 찍고있는데

커스터마이징이 잘 안되서 별도로 찍기로 함

 

@SpringBootApplication
@EnableScheduling
class ApiApplication(
        val dataSource: DataSource) {

    @Scheduled(fixedDelay = 10000)
    fun hikariPoolMonitor() {
        (DirectFieldAccessor(dataSource).getPropertyValue("pool") as HikariPool?)?.let { hikariPool ->
            logger().info("Pool stats (total=${hikariPool.totalConnections}, active=${hikariPool.activeConnections}, idle=${hikariPool.idleConnections}, waiting=${hikariPool.threadsAwaitingConnection})")
        }
    }
}

 

2020-04-28 11:22:58,868 INFO  [scheduling-1] [||] [n.d.api.ApiApplication:23] : Pool stats (total=50, active=0, idle=50, waiting=0)
2020-04-28 11:23:08,868 INFO  [scheduling-1] [||] [n.d.api.ApiApplication:23] : Pool stats (total=50, active=0, idle=50, waiting=0)
2020-04-28 11:23:18,869 INFO  [scheduling-1] [||] [n.d.api.ApiApplication:23] : Pool stats (total=50, active=0, idle=50, waiting=0)
  Comments,   0  Trackbacks
댓글 쓰기