public static void dumpVmMetrics ( String incidentId ) { PrintWriter writer = null ; try { String dumpFile = EventUtil . getDumpPathPrefix ( ) + "/" + INC_DUMP_FILE_NAME + incidentId + INC_DUMP_FILE_EXT ; final OutputStream outStream = new GZIPOutputStream ( new FileOutputStream ( dumpFile ) ) ; writer = new PrintWriter ( outStream , true ) ; final VirtualMachineMetrics vm = VirtualMachineMetrics . getInstance ( ) ; writer . print ( "\n\n\n--------------------------- METRICS " + "---------------------------\n\n" ) ; writer . flush ( ) ; JsonFactory jf = new JsonFactory ( ) ; jf . disable ( JsonGenerator . Feature . AUTO_CLOSE_TARGET ) ; ObjectMapper mapper = new ObjectMapper ( jf ) ; mapper . registerModule ( new JodaModule ( ) ) ; mapper . setDateFormat ( new ISO8601DateFormat ( ) ) ; mapper . configure ( SerializationFeature . INDENT_OUTPUT , true ) ; MetricsServlet metrics = new MetricsServlet ( Clock . defaultClock ( ) , vm , Metrics . defaultRegistry ( ) , jf , true ) ; final JsonGenerator json = jf . createGenerator ( outStream , JsonEncoding . UTF8 ) ; json . useDefaultPrettyPrinter ( ) ; json . writeStartObject ( ) ; // JVM metrics writeVmMetrics ( json , vm ) ; // Components metrics metrics . writeRegularMetrics ( json , // json generator null , // class prefix false ) ; // include full samples json . writeEndObject ( ) ; json . close ( ) ; logger . debug ( "Creating full thread dump in dump file {}" , dumpFile ) ; // Thread dump next.... writer . print ( "\n\n\n--------------------------- THREAD DUMP " + "---------------------------\n\n" ) ; writer . flush ( ) ; vm . threadDump ( outStream ) ; logger . debug ( "Dump file {} is created." , dumpFile ) ; } catch ( Exception exc ) { logger . error ( "Unable to write dump file, exception: {}" , exc . getMessage ( ) ) ; } finally { if ( writer != null ) { writer . close ( ) ; } } }
Dumps JVM metrics for this process .