-
Notifications
You must be signed in to change notification settings - Fork 828
Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer #1735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer #1735
Conversation
88a37c6 to
c0e1019
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances the configurability of the Prometheus Java HTTP server by allowing users to customize the metrics endpoint path and control whether the health endpoint is registered. The changes maintain backward compatibility with sensible defaults (/metrics and health handler enabled by default).
Key changes:
- Added
metricsHandlerPath()builder method to customize the metrics endpoint (defaults to/metrics) - Added
registerHealthHandler()builder method to optionally disable the health endpoint (defaults totrue) - Updated
DefaultHandlerto dynamically generate HTML documentation based on the configured metrics path
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| HTTPServer.java | Added constructor parameters and builder methods for configurable metrics path and health handler registration |
| DefaultHandler.java | Updated constructor to accept metrics path parameter and generate dynamic HTML links based on the configured path |
| HTTPServerTest.java | Added tests to verify custom metrics path and health handler enable/disable functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java
Outdated
Show resolved
Hide resolved
...-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java
Outdated
Show resolved
Hide resolved
...-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java
Outdated
Show resolved
Hide resolved
...-exporter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/HTTPServer.java
Outdated
Show resolved
Hide resolved
...orter-httpserver/src/main/java/io/prometheus/metrics/exporter/httpserver/DefaultHandler.java
Outdated
Show resolved
Hide resolved
2d8cf20 to
b5395c3
Compare
|
I've rebased the branch and applied the review comments from Copilot. |
b5395c3 to
dfa2356
Compare
…options to HTTPServer Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
dfa2356 to
1cec50b
Compare
|
Thanks a lot for the contribution 😄 |
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
metricsHandlerEndpointoption in theHTTPServer.Builder. The default remains/metrics, but it can now be changed as needed. [1] [2] [3] [4]registerHealthHandleroption in theHTTPServer.Builderto control whether the health endpoint (/-/healthy) is registered. By default, it is enabled. [1] [2] [3] [4]Default handler updates
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