From 9f441edb5532c617de494063e2dd30b84659e087 Mon Sep 17 00:00:00 2001 From: Naseem Date: Sun, 15 Dec 2019 12:45:41 -0500 Subject: [PATCH] feat: add status label --- getting-started/monitored-example/monitoring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }