Class PrometheusText

java.lang.Object
com.jsgalactic.axiom.metrics.PrometheusText

public final class PrometheusText extends Object
Renders a MetricsRegistry in the Prometheus text exposition format, version 0.0.4.

Dots in names become underscores. Counters get a _total suffix, and timers are exposed in seconds as a histogram: cumulative _bucket series with an le tag, _sum and _count. Every metric with help text (set on the registry, or built in for the runtime's own metrics) gets a # HELP line, and the registry's own size and dropped series are exposed as axiom_metrics_series and axiom_metrics_dropped_series_total. Output order is stable. A timer's _count and its +Inf bucket are always equal; its _sum may lag them by observations recorded while the registry was being read. Tag values are escaped; no value is ever interpreted.

The metrics describe the application's routes and load. Serve them on a private network or behind authentication, never publicly; see the observability guide.

  • Field Details

  • Method Details

    • render

      public static String render(MetricsRegistry registry)
      Renders every series of a registry.
      Parameters:
      registry - registry to read
      Returns:
      exposition text, empty for an empty registry
    • handler

      public static Handler handler(MetricsRegistry registry)
      Returns a handler that answers with the registry's current exposition, for example app.get("/metrics", PrometheusText.handler(registry), security.hasRole("ops")).
      Parameters:
      registry - registry to read on every request
      Returns:
      a handler answering 200 with CONTENT_TYPE