Skip to content

metrics can be attached to specific endpoint programatically, but will raise TS2339 #44

Description

@arnaudruffin

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:

import expressPromBundle from "express-prom-bundle";
const PROMETHEUS_BUNDLE = expressPromBundle({...})
[...]
expressApp.route("/metrics").get(function (req, res) {
            PROMETHEUS_BUNDLE.metricsMiddleware(req, res);
        });

Here is how I try to do it now (with the error TS2339):

expressApp.use("/metrics", PROMETHEUS_BUNDLE_METRICS_MIDDLEWARE.metricsMiddleware);

This is only a typing issue and does not prevent my server from running correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions