client_java icon indicating copy to clipboard operation
client_java copied to clipboard

Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer

Open Donnerbart opened this issue 1 month ago • 0 comments

Hey @fstab, long time no see.

We would like to use this exporter in our project, but need to customize the metrics endpoint and disable the health handler. I hope this small contribution can make into a release.

Summary

This pull request enhances the configurability of the Prometheus Java HTTP server by allowing customization of the metrics endpoint path and making the health endpoint registration optional. It also updates the default HTML handler to reflect these changes and adds tests to ensure correct behavior.

Configuration improvements

  • Added support for customizing the metrics endpoint via the new metricsHandlerEndpoint option in the HTTPServer.Builder. The default remains /metrics, but it can now be changed as needed. [1] [2] [3] [4]
  • Introduced a registerHealthHandler option in the HTTPServer.Builder to control whether the health endpoint (/-/healthy) is registered. By default, it is enabled. [1] [2] [3] [4]

Default handler updates

  • Updated the DefaultHandler to accept the metrics path as a parameter and generate all documentation links and examples based on the configured path, ensuring consistency in the UI and documentation. [1] [2]

Testing

  • Added tests to verify that the metrics endpoint can be customized and that the health endpoint can be enabled or disabled as configured. [1] [2]

Donnerbart avatar Dec 11 '25 13:12 Donnerbart