Class HttpErrorHandlingPolicy

Object
HttpErrorHandlingPolicy

@StableApi public final class HttpErrorHandlingPolicy extends Object
Controls how the HTTPServer handles exceptions raised while scraping metrics.

The default policy built by builder() does not expose exception details and does not report the exception. Configure the builder to route diagnostic details to an application-appropriate sink.

  • Method Details

    • builder

      Returns a builder for configuring scrape error handling.

      The builder defaults to a generic HTTP 500 response with no error reporter. This avoids exposing exception details to scrape clients or adding an implicit dependency on an application's logging configuration.

    • julReporter

      public static Consumer<Throwable> julReporter()
      Returns a synchronous reporter that logs scrape exceptions at Level.SEVERE using JUL.

      Reporting is opt-in; the default policy does not log scrape exceptions.