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) { if (enableCreateDumps && dumpsPathExists) {
executorService.scheduleAtFixedRate({ dumpCheckTask(dumpsPath) }, 0, 30, TimeUnit.MINUTES) executorService.scheduleAtFixedRate({ dumpCheckTask(dumpsPath) }, 0, 30, TimeUnit.MINUTES)
configHeapDump(dumpsPath) val appName = envVars["DSHACKLE_APP_NAME"] ?: "dshackle"
configHeapDump(dumpsPath, appName)
} else { } else {
log.warn("Heap dump creation is turned off") 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 date = SimpleDateFormat("yyyyMMddHHmmss").format(Date())
val fileName = "$dumpsPath/heap_$date.hprof" val fileName = "$dumpsPath/heap_${date}_$appName.hprof"
val bean = ManagementFactory.newPlatformMXBeanProxy( val bean = ManagementFactory.newPlatformMXBeanProxy(
ManagementFactory.getPlatformMBeanServer(), ManagementFactory.getPlatformMBeanServer(),

View File

@@ -1,7 +1,7 @@
spring: spring:
application: application:
max-metadata-size: ${MAX_METADATA_SIZE:16384} max-metadata-size: ${MAX_METADATA_SIZE:16384}
name: ${DRPC_APP_NAME:dshackle} name: ${DSHACKLE_APP_NAME:dshackle}
zipkin: zipkin:
enabled: ${ENABLE_COLLECT_SPANS:false} enabled: ${ENABLE_COLLECT_SPANS:false}
base-url: ${ZIPKIN_URL:https://trace.drpc.dev/} base-url: ${ZIPKIN_URL:https://trace.drpc.dev/}