monitoring: allow setting a custom metrics handler pattern
Currently, there is no option to set a custom pattern for the metrics handler when using the monitoring
package (it's hardcoded as /metrics
).
We're currently working on integrating the monitoring package in the GitLab Container Registry, where we already expose metrics and provide a configuration setting that allows users to override the handler pattern (docs), which also defaults to /metrics
. To be able to rely on the monitoring
package while avoiding breaking changes, we need to continue to support this.
This MR proposes the addition of a new monitoring.WithMetricsHandlerPattern(pattern string)
option, which allows users to define a custom pattern for the metrics handler. The default remains /metrics
if this option is not specified.