exporter/prometheus: Expose express request handler
jacekjagiello opened this issue · 0 comments
jacekjagiello commented
Is your feature request related to a problem? Please describe.
I would like to expose metrics from my app, without having to create a separate HTTP server for metrics endpoint.
Currently, PrometheusStatsExporter can only start a new HTTP server on the configured port. It does not expose an API that would allow integrating metrics endpoint to my app.
Describe the solution you'd like
Because Prometheus exporter leverages express to create an HTTP server, the simplest solution would be to expose express request handler, which can be further attached to the router of application.
Example:
const myApp = express()
const exporter = new PrometheusStatsExporter()
myApp.get('/metrics', exporter.getRequestHandler())
If this feature makes sense to you, I'll be happy to open PR 😉