Add app name to dump filename (#397)

This commit is contained in:
KirillPamPam
2024-01-15 14:59:34 +04:00
committed by GitHub
parent 5be87b8ad5
commit b6cec204c9
2 changed files with 6 additions and 4 deletions

View File

@@ -35,15 +35,17 @@ class HeapDumpCreator {
if (enableCreateDumps && dumpsPathExists) {
executorService.scheduleAtFixedRate({ dumpCheckTask(dumpsPath) }, 0, 30, TimeUnit.MINUTES)
configHeapDump(dumpsPath)
val appName = envVars["DSHACKLE_APP_NAME"] ?: "dshackle"
configHeapDump(dumpsPath, appName)
} else {
log.warn("Heap dump creation is turned off")
}
}
private fun configHeapDump(dumpsPath: String) {
private fun configHeapDump(dumpsPath: String, appName: String) {
val date = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
val fileName = "$dumpsPath/heap_$date.hprof"
val fileName = "$dumpsPath/heap_${date}_$appName.hprof"
val bean = ManagementFactory.newPlatformMXBeanProxy(
ManagementFactory.getPlatformMBeanServer(),