Class TraceEventViewer


  • public final class TraceEventViewer
    extends java.lang.Object
    This class converts from the Trace Event json data into a full HTML page. It includes the trace viewer from Catapult, the Chromium trace UI.

    This class is separate from TraceEventWriter, because it includes a fairly large HTML chunk, and brings in a differently licenced piece of code.

    This code is NOT API stable, and may be removed in the future, or changed without notice.

    Since:
    0.17.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String INLINE_TRACE_DATA  
      private static java.util.logging.Logger logger  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TraceEventViewer()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String readAll​(java.io.InputStream stream)  
      private static java.lang.String replaceIndexTraceData​(java.lang.String index, java.lang.String replacement)  
      private static java.lang.String replaceIndexTraceImport​(java.lang.String index, java.lang.String replacement, java.lang.String inlineTraceData64)
      Replaces the normal <link> tag in index.html with a custom replacement, and optionally the inlined Trace data as a base64 script.
      private static java.lang.String replaceIndexWebComponents​(java.lang.String index, java.lang.String replacement)  
      private static java.lang.String trimTraceViewer​(java.lang.String traceViewer)  
      static java.nio.file.Path writeTraceHtml()
      A convenience function around writeTraceHtml(Writer).
      static void writeTraceHtml​(java.io.Writer writer)
      Writes all available trace data as a single HTML file into the given writer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • INLINE_TRACE_DATA

        private static final java.lang.String INLINE_TRACE_DATA
        See Also:
        Constant Field Values
    • Constructor Detail

      • TraceEventViewer

        private TraceEventViewer()
    • Method Detail

      • writeTraceHtml

        public static java.nio.file.Path writeTraceHtml()
                                                 throws java.io.IOException
        A convenience function around writeTraceHtml(Writer). This writes the trace data to a temporary file and logs the output location.
        Returns:
        the Path of the written file.
        Throws:
        java.io.IOException - if it can't write to the destination.
      • writeTraceHtml

        public static void writeTraceHtml​(java.io.Writer writer)
                                   throws java.io.IOException
        Writes all available trace data as a single HTML file into the given writer.
        Parameters:
        writer - The destination to write all HTML to.
        Throws:
        java.io.IOException - if it can't write to the writer.
      • replaceIndexTraceImport

        private static java.lang.String replaceIndexTraceImport​(java.lang.String index,
                                                                java.lang.String replacement,
                                                                java.lang.String inlineTraceData64)
        Replaces the normal <link> tag in index.html with a custom replacement, and optionally the inlined Trace data as a base64 script. This is because the trace2html.html file imports the data as a top level text/plain script.
      • replaceIndexWebComponents

        private static java.lang.String replaceIndexWebComponents​(java.lang.String index,
                                                                  java.lang.String replacement)
      • replaceIndexTraceData

        private static java.lang.String replaceIndexTraceData​(java.lang.String index,
                                                              java.lang.String replacement)
      • trimTraceViewer

        private static java.lang.String trimTraceViewer​(java.lang.String traceViewer)
      • readAll

        private static java.lang.String readAll​(java.io.InputStream stream)
                                         throws java.io.IOException
        Throws:
        java.io.IOException