diff --git a/getting-started/monitored-example/monitoring.js b/getting-started/monitored-example/monitoring.js index 070d9d01ef8..4f672be8f11 100644 --- a/getting-started/monitored-example/monitoring.js +++ b/getting-started/monitored-example/monitoring.js @@ -18,7 +18,7 @@ meter.addExporter( const requestCount = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], + labelKeys: ["route", "status"], description: "Count all incoming requests" }); @@ -27,7 +27,7 @@ const handles = new Map(); module.exports.countAllRequests = () => { return (req, res, next) => { if (!handles.has(req.path)) { - const labelSet = meter.labels({ route: req.path }); + const labelSet = meter.labels({ route: req.path, status: res.statusCode }); const handle = requestCount.getHandle(labelSet); handles.set(req.path, handle); }