Closed Nerexbcd closed 7 months ago
After some research, I decided to try to create my own metrics integrations, when i started, I ended up getting the same error.
This time I wanted to try to understand the error, the error is basically saying that the function register.metrics()
(considering that the variable register
was created like: const register = new client.Registry();
), from the prom-client, is returning a promisse instead of a string, witch is making the http server give an error.
I solved the problem on my code by changing on the http server request to await for the register.metrics()
function, and my code started working again.
With this I'm thinking that in old versions of the prom-client the function register.metrics()
returned a string, but now returns a promisse.
The solution would be on the example on the readme change the /metrics
http request to be async and wait on promRegister.metrics()
.
fix for the README of the repository ( just replace the old "expose metrics endpoint" section with this)
// expose metrics endpoint
app.get('/metrics', async (req, res) => {
res.set('Content-Type', promRegister.contentType)
res.end(await promRegister.metrics())
})
Made fix on pull request: #83
Hi!
When I try to access the
/metrics
i get this error: