Skip to content

Commit f139246

Browse files
committed
add connection info to health readout
1 parent b80b3c1 commit f139246

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

project/core/lib/db/application/src/main/kotlin/vdi/core/db/app/health/DatabaseDependency.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package vdi.core.db.app.health
22

3+
import com.zaxxer.hikari.HikariDataSource
34
import org.slf4j.LoggerFactory
45
import vdi.core.db.app.TargetDatabaseReference
56
import vdi.core.health.Dependency
@@ -15,7 +16,7 @@ class DatabaseDependency(
1516
protocol = "",
1617
host = connection.details.server.host,
1718
port = connection.details.server.port,
18-
extra = extra.appendDbInfo(connection.details),
19+
extra = extra.appendDbInfo(connection.details, connection.dataSource as HikariDataSource),
1920
) {
2021
override fun checkStatus() =
2122
when (connection.details.platform) {
@@ -37,12 +38,14 @@ class DatabaseDependency(
3738
}
3839
}
3940

40-
private fun Map<String, Any>.appendDbInfo(entry: TargetDatabaseDetails): Map<String, Any> {
41+
private fun Map<String, Any>.appendDbInfo(entry: TargetDatabaseDetails, ref: HikariDataSource): Map<String, Any> {
4142
val map = this as? MutableMap ?: this.toMutableMap()
4243

4344
map["platform"] = entry.platform.name
4445
map["host"] = entry.server.host
4546
map["controlSchema"] = entry.schema
47+
map["activeConnections"] = ref.hikariPoolMXBean.activeConnections
48+
map["idleConnections"] = ref.hikariPoolMXBean.idleConnections
4649

4750
return map
4851
}

0 commit comments

Comments
 (0)