-
Notifications
You must be signed in to change notification settings - Fork 67
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
metrics can be attached to specific endpoint programatically, but will raise TS2339 #44
Comments
I have the same problem. I think this line is wrong: // /types/index.d.ts
declare function express_prom_bundle(opts: express_prom_bundle.Opts): RequestHandler; It should be something like: declare function express_prom_bundle(opts: express_prom_bundle.Opts):
{
metrics: ...
metricsMiddleware: RequestHandler,
promClient: ...
} Maybe @raszi can put a bit of light on this? I would be happy to help with a PR |
That is not the correct way to use the library AFAIK: import * as promBundle from 'express-prom-bundle'
const metricsMiddleware = promBundle({...});
expressApp.route("/metrics").get(function (req, res) {
return metricsMiddleware(req, res);
}); Or more simply as the documentation says: import * as promBundle from 'express-prom-bundle'
const metricsMiddleware = promBundle({...});
expressApp.use(metricsMiddleware); |
The type tests might also help you here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I am attaching metrics programatically in TypeScript. This used to work fine with a previous version (5.0.2) but with recent updates I now have a TypeScript error:
error TS2339: Property 'metricsMiddleware' does not exist on type 'RequestHandler'.
Here is how I used to do it in 5.0.2:
Here is how I try to do it now (with the error TS2339):
This is only a typing issue and does not prevent my server from running correctly.
The text was updated successfully, but these errors were encountered: