Class TextFormat


  • public class TextFormat
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CONTENT_TYPE_004
      Content-type for Prometheus text version 0.0.4.
      static java.lang.String CONTENT_TYPE_OPENMETRICS_100
      Content-type for Openmetrics text version 1.0.0.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextFormat()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String chooseContentType​(java.lang.String acceptHeader)
      Return the content type that should be used for a given Accept HTTP header.
      private static java.lang.String omTypeString​(Collector.Type t)  
      (package private) static void omWriteTimestamp​(java.io.Writer writer, long timestampMs)  
      private static java.lang.String typeString​(Collector.Type t)  
      static void write004​(java.io.Writer writer, java.util.Enumeration<Collector.MetricFamilySamples> mfs)
      Write out the text version 0.0.4 of the given MetricFamilySamples.
      private static void writeEscapedHelp​(java.io.Writer writer, java.lang.String s)  
      private static void writeEscapedLabelValue​(java.io.Writer writer, java.lang.String s)  
      static void writeFormat​(java.lang.String contentType, java.io.Writer writer, java.util.Enumeration<Collector.MetricFamilySamples> mfs)
      Write out the given MetricFamilySamples in a format per the contentType.
      static void writeOpenMetrics100​(java.io.Writer writer, java.util.Enumeration<Collector.MetricFamilySamples> mfs)
      Write out the OpenMetrics text version 1.0.0 of the given MetricFamilySamples.
      • Methods inherited from class java.lang.Object

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

      • CONTENT_TYPE_004

        public static final java.lang.String CONTENT_TYPE_004
        Content-type for Prometheus text version 0.0.4.
        See Also:
        Constant Field Values
      • CONTENT_TYPE_OPENMETRICS_100

        public static final java.lang.String CONTENT_TYPE_OPENMETRICS_100
        Content-type for Openmetrics text version 1.0.0.
        Since:
        0.10.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • TextFormat

        public TextFormat()
    • Method Detail

      • chooseContentType

        public static java.lang.String chooseContentType​(java.lang.String acceptHeader)
        Return the content type that should be used for a given Accept HTTP header.
        Since:
        0.10.0
      • writeFormat

        public static void writeFormat​(java.lang.String contentType,
                                       java.io.Writer writer,
                                       java.util.Enumeration<Collector.MetricFamilySamples> mfs)
                                throws java.io.IOException
        Write out the given MetricFamilySamples in a format per the contentType.
        Throws:
        java.io.IOException
        Since:
        0.10.0
      • write004

        public static void write004​(java.io.Writer writer,
                                    java.util.Enumeration<Collector.MetricFamilySamples> mfs)
                             throws java.io.IOException
        Write out the text version 0.0.4 of the given MetricFamilySamples.
        Throws:
        java.io.IOException
      • writeEscapedHelp

        private static void writeEscapedHelp​(java.io.Writer writer,
                                             java.lang.String s)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEscapedLabelValue

        private static void writeEscapedLabelValue​(java.io.Writer writer,
                                                   java.lang.String s)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • typeString

        private static java.lang.String typeString​(Collector.Type t)
      • writeOpenMetrics100

        public static void writeOpenMetrics100​(java.io.Writer writer,
                                               java.util.Enumeration<Collector.MetricFamilySamples> mfs)
                                        throws java.io.IOException
        Write out the OpenMetrics text version 1.0.0 of the given MetricFamilySamples.
        Throws:
        java.io.IOException
        Since:
        0.10.0
      • omWriteTimestamp

        static void omWriteTimestamp​(java.io.Writer writer,
                                     long timestampMs)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • omTypeString

        private static java.lang.String omTypeString​(Collector.Type t)