From 7eae5d4b7fa36bd4e3799645f5b0ed7a53a797e9 Mon Sep 17 00:00:00 2001 From: Cellaryllis <95936504+Cellaryllis@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:15:47 +0100 Subject: [PATCH 1/2] Add another example for normalizePath --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 88f6404..2f1af5a 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,17 @@ promBundle.normalizePath = (req, opts) => { }; ``` +#### Example 3 (return express route definition): + +```javascript +app.use(promBundle(/* options? */)); + +promBundle.normalizePath = (req, opts) => { + // Return the path of the express route (i.e. /v1/member/:id or /v1/timer/automated/:userid/:timerid") + return req.route?.path ?? "NULL"; +}; +``` + For more details: * [url-value-parser](https://www.npmjs.com/package/url-value-parser) - magic behind automatic path normalization * [normalizePath.js](https://github.com/jochen-schweizer/express-prom-bundle/blob/master/src/normalizePath.js) - source code for path processing From c54182465718bcd814d3c98d000776f914a48786 Mon Sep 17 00:00:00 2001 From: Cellaryllis <95936504+Cellaryllis@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:18:11 +0100 Subject: [PATCH 2/2] Move details below example 2 --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2f1af5a..9c07c22 100644 --- a/README.md +++ b/README.md @@ -142,22 +142,22 @@ promBundle.normalizePath = (req, opts) => { }; ``` +For more details: + * [url-value-parser](https://www.npmjs.com/package/url-value-parser) - magic behind automatic path normalization + * [normalizePath.js](https://github.com/jochen-schweizer/express-prom-bundle/blob/master/src/normalizePath.js) - source code for path processing + + #### Example 3 (return express route definition): ```javascript app.use(promBundle(/* options? */)); promBundle.normalizePath = (req, opts) => { - // Return the path of the express route (i.e. /v1/member/:id or /v1/timer/automated/:userid/:timerid") + // Return the path of the express route (i.e. /v1/user/:id or /v1/timer/automated/:userid/:timerid") return req.route?.path ?? "NULL"; }; ``` -For more details: - * [url-value-parser](https://www.npmjs.com/package/url-value-parser) - magic behind automatic path normalization - * [normalizePath.js](https://github.com/jochen-schweizer/express-prom-bundle/blob/master/src/normalizePath.js) - source code for path processing - - ## express example setup std. metrics but exclude `up`-metric: