Skip to content
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

Breaking change in prom-client 13.0.0 returns empty response for /metrics #71

Closed
lunae opened this issue Dec 21, 2020 · 2 comments
Closed

Comments

@lunae
Copy link

lunae commented Dec 21, 2020

Hi all! Awesome work with express-prom-bundle. Was giving it a try this weekend and it seems like the latest release of prom-client (13.0.0) broke the /metrics endpoint. Digging into the issue I found that prom-client@13.0.0 has breaking changes to metrics(). It now returns a promise. https://github.com/siimon/prom-client/releases/tag/v13.0.0. When using curl to test the endpoint it responds with an empty reply.

package.json

{
  "name": "express-prom-bundle-with-13-0-0",
  "version": "1.0.0",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "^4.17.1",
    "express-prom-bundle": "^6.3.0",
    "prom-client": "^13.0.0"
  }
}

app.js

const express = require('express')
const prometheus = require("express-prom-bundle")

const app = express()

const metricsMiddleware = prometheus({
    includeStatusCode: true,
    includeMethod: true,
    includePath: true
})

app.use(metricsMiddleware)

app.listen(3000)

I believe the issue is in metricsMiddleware https://github.com/jochen-schweizer/express-prom-bundle/blob/master/src/index.js#L125-L128. I'm sort of new to both prom-client and express-prom-bundle and not quite sure if this is the only spot affected by the change but hope that this helps.

const metricsMiddleware = async function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(await opts.promRegistry.metrics());
};
@lunae lunae changed the title Incompatible with prom-client 13.0.0 Breaking change in prom-client 13.0.0 returns empty response for /metrics Dec 21, 2020
@palmer-cl
Copy link

I am also seeing this issue. Error:

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Promise

Relevant stack:
at metricsMiddleware (/usr/src/app/node_modules/express-prom-bundle/src/index.js:127:9) at middleware (/usr/src/app/node_modules/express-prom-bundle/src/index.js:137:16)

@disjunction
Copy link
Collaborator

Thanks for the tips guys. I made a compatibility patch, so the library now supports both 12 and 13 versions of prom-client. I've just published it on npm as version 6.3.1.

As for the future, I hope to rewrite this whole thing in typescript as version 7. At that point I'll simply drop the support for the old library. (testing different version of peer dependency is a pain).

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

No branches or pull requests

3 participants