getHeapDumpPath checks for volume service with heap-dump tag and returns path
()
| 187 | |
| 188 | // getHeapDumpPath checks for volume service with heap-dump tag and returns path |
| 189 | func (j *JVMKillAgent) getHeapDumpPath() string { |
| 190 | // Check VCAP_SERVICES for volume service with heap-dump tag |
| 191 | vcapServices, err := common.GetVCAPServices() |
| 192 | if err != nil { |
| 193 | return "" |
| 194 | } |
| 195 | |
| 196 | // Look for volume service with "heap-dump" tag |
| 197 | for _, services := range vcapServices { |
| 198 | for _, service := range services { |
| 199 | if service.HasTag("heap-dump") { |
| 200 | // Extract volume mount path from credentials |
| 201 | if volumeMounts, ok := service.Credentials["volume_mounts"].([]interface{}); ok && len(volumeMounts) > 0 { |
| 202 | if mount, ok := volumeMounts[0].(map[string]interface{}); ok { |
| 203 | if containerDir, ok := mount["container_dir"].(string); ok { |
| 204 | // Build heap dump path |
| 205 | // Format: /container/dir/space-id/app-id/instance-index.hprof |
| 206 | appDetails := j.getAppDetails() |
| 207 | return filepath.Join(containerDir, |
| 208 | appDetails.spaceID, |
| 209 | appDetails.appID, |
| 210 | "$CF_INSTANCE_INDEX-%FT%T%z-${CF_INSTANCE_GUID:0:8}.hprof") |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | return "" |
| 219 | } |
| 220 | |
| 221 | // appDetails holds application identification info |
| 222 | type appDetails struct { |
no test coverage detected