Skip to content

Conversation

@Donnerbart
Copy link
Contributor

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 Donnerbart changed the title feat: Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer Add metricsHandlerPath and registerHealthHandler configuration options to HTTPServer Dec 12, 2025
@Donnerbart Donnerbart force-pushed the feature/add-configuration-options-for-httpserver branch from 88a37c6 to c0e1019 Compare December 12, 2025 07:11
@zeitlinger zeitlinger requested a review from Copilot December 16, 2025 11:41
Copy link
Contributor

Copilot AI left a 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 to true)
  • Updated DefaultHandler to 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.

@Donnerbart Donnerbart force-pushed the feature/add-configuration-options-for-httpserver branch 2 times, most recently from 2d8cf20 to b5395c3 Compare December 18, 2025 13:39
@Donnerbart
Copy link
Contributor Author

I've rebased the branch and applied the review comments from Copilot.

@Donnerbart Donnerbart force-pushed the feature/add-configuration-options-for-httpserver branch from b5395c3 to dfa2356 Compare December 19, 2025 13:43
…options to HTTPServer

Signed-off-by: David Sondermann <david.sondermann@hivemq.com>
@Donnerbart Donnerbart force-pushed the feature/add-configuration-options-for-httpserver branch from dfa2356 to 1cec50b Compare December 20, 2025 09:31
@zeitlinger zeitlinger enabled auto-merge (squash) December 20, 2025 09:43
@zeitlinger
Copy link
Member

Thanks a lot for the contribution 😄

@zeitlinger zeitlinger merged commit fd7bef6 into prometheus:main Dec 20, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants