Class PrometheusHandler

  • All Implemented Interfaces:
    org.forgerock.http.Handler

    public final class PrometheusHandler
    extends Object
    implements org.forgerock.http.Handler
    An HTTP Handler from which Prometheus and OpenTelemetry Collector can scrape monitoring information.
    • Field Detail

      • SUPPORTED_HTTP_METHODS

        public static final List<String> SUPPORTED_HTTP_METHODS
        List of HTTP methods supported by a Prometheus Handler.
    • Method Detail

      • prometheusHandler

        public static PrometheusHandler prometheusHandler​(String metricPrefix,
                                                          Supplier<MeterRegistry> meterRegistrySupplier,
                                                          BooleanSupplier compliantOutputFormat)
        Returns a new Prometheus Handler which can be switched to use different output formats.
        Parameters:
        metricPrefix - The prefix that will be prepended before each metric. Ideally this will be the product specific prefix.
        meterRegistrySupplier - A Supplier of the MetricRegistry which will be used to collect metrics to include in HTTP response sent by this PrometheusHandler.
        compliantOutputFormat - Returns a boolean used to switch the prometheus handler output format from compliant (if true) to legacy (if false)
        Returns:
        a new PrometheusHandler
      • handle

        public Promise<org.forgerock.http.protocol.Response,​NeverThrowsException> handle​(org.forgerock.services.context.Context context,
                                                                                               org.forgerock.http.protocol.Request request)
        Specified by:
        handle in interface org.forgerock.http.Handler