Class MicrometerPrometheusFormatter

java.lang.Object
io.helidon.metrics.providers.micrometer.MicrometerPrometheusFormatter
All Implemented Interfaces:
MeterRegistryFormatter

public class MicrometerPrometheusFormatter extends Object implements MeterRegistryFormatter
Retrieves and prepares meter output from the specified meter registry according to the formats supported by the Prometheus meter registry.

Because the Prometheus exposition format is flat, and because some meter types have multiple values, the meter names in the output repeat the actual meter name with suffixes to indicate the specific quantities (e.g., count, total, max) each reported value conveys. Further, meter names in the output might need the prefix "m_" if the actual meter name starts with a digit or underscore and underscores replace special characters.

  • Field Details

    • MEDIA_TYPE_TO_FORMAT

      public static final Map<MediaType,String> MEDIA_TYPE_TO_FORMAT
      Mapping from supported media types to the corresponding Prometheus registry content types.
  • Method Details

    • builder

      public static MicrometerPrometheusFormatter.Builder builder(MeterRegistry meterRegistry)
      Returns a new builder for constructing a formatter.
      Parameters:
      meterRegistry - the MeterRegistry from which to build the Prometheus output
      Returns:
      new builder
    • normalizeNameToPrometheus

      public static String normalizeNameToPrometheus(String name)
      Convert the meter or tag name to the format used by the Prometheus simple client.
      Parameters:
      name - original name
      Returns:
      normalized name
    • format

      public Optional<Object> format()
      Returns the Prometheus output governed by the previously-specified media type, optionally filtered by the previously-specified scope and meter name selections.
      Specified by:
      format in interface MeterRegistryFormatter
      Returns:
      filtered Prometheus output
    • formatMetadata

      public Optional<Object> formatMetadata()
      Description copied from interface: MeterRegistryFormatter
      Formats the meter registry's metadata.
      Specified by:
      formatMetadata in interface MeterRegistryFormatter
      Returns:
      formatted metadata output