client_java
client_java copied to clipboard
Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer
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
metricsHandlerEndpointoption in theHTTPServer.Builder. The default remains/metrics, but it can now be changed as needed. [1] [2] [3] [4] - Introduced a
registerHealthHandleroption in theHTTPServer.Builderto control whether the health endpoint (/-/healthy) is registered. By default, it is enabled. [1] [2] [3] [4]
Default handler updates
- Updated the
DefaultHandlerto 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]