@k03mad/simple-prom 2.2.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/lib/register.js +9 -2
- package/app/lib/server.js +3 -2
- package/package.json +6 -8
package/app/lib/register.js
CHANGED
|
@@ -8,15 +8,22 @@ import client from 'prom-client';
|
|
|
8
8
|
* @param {string} opts.appName
|
|
9
9
|
* @param {string|number} opts.port
|
|
10
10
|
* @param {object} opts.metrics
|
|
11
|
+
* @param {string[]} [opts.metricsTurnOff]
|
|
11
12
|
*/
|
|
12
|
-
export const registerMetrics = ({appName, port, metrics}) => {
|
|
13
|
+
export const registerMetrics = ({appName, port, metrics, metricsTurnOff = []}) => {
|
|
14
|
+
const filteredMetrics = Object.fromEntries(
|
|
15
|
+
Object.entries(metrics).filter(
|
|
16
|
+
([key]) => !metricsTurnOff.includes(key),
|
|
17
|
+
),
|
|
18
|
+
);
|
|
19
|
+
|
|
13
20
|
const register = new client.Registry();
|
|
14
21
|
|
|
15
22
|
client.collectDefaultMetrics({register});
|
|
16
23
|
register.setDefaultLabels({app: appName, port, host: os.hostname});
|
|
17
24
|
|
|
18
25
|
Object
|
|
19
|
-
.values(
|
|
26
|
+
.values(filteredMetrics)
|
|
20
27
|
.forEach(metric => {
|
|
21
28
|
const {collect, name, ...rest} = metric;
|
|
22
29
|
|
package/app/lib/server.js
CHANGED
|
@@ -14,10 +14,11 @@ import {registerMetrics} from './register.js';
|
|
|
14
14
|
* @param {string} opts.appName
|
|
15
15
|
* @param {string|number} opts.port
|
|
16
16
|
* @param {object} opts.metrics
|
|
17
|
+
* @param {string[]} opts.metricsTurnOff
|
|
17
18
|
* @param {boolean} opts.debug
|
|
18
19
|
*/
|
|
19
|
-
export const startMetricsServer = ({appName, port, metrics, debug}) => {
|
|
20
|
-
const register = registerMetrics({appName, port, metrics});
|
|
20
|
+
export const startMetricsServer = ({appName, port, metrics, metricsTurnOff, debug}) => {
|
|
21
|
+
const register = registerMetrics({appName, port, metrics, metricsTurnOff});
|
|
21
22
|
|
|
22
23
|
const app = express();
|
|
23
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k03mad/simple-prom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Simple prom-client library",
|
|
5
5
|
"maintainers": [
|
|
6
6
|
"Kirill Molchanov <k03.mad@gmail.com"
|
|
@@ -16,26 +16,24 @@
|
|
|
16
16
|
"node": ">=20"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@k03mad/simple-date": "1.0
|
|
20
|
-
"@k03mad/simple-log": "2.
|
|
19
|
+
"@k03mad/simple-date": "1.1.0",
|
|
20
|
+
"@k03mad/simple-log": "2.2.0",
|
|
21
21
|
"chalk": "5.3.0",
|
|
22
22
|
"compression": "1.7.4",
|
|
23
23
|
"express": "4.19.2",
|
|
24
24
|
"helmet": "7.1.0",
|
|
25
25
|
"morgan": "1.10.0",
|
|
26
|
-
"prom-client": "15.1.
|
|
26
|
+
"prom-client": "15.1.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@k03mad/eslint-config": "
|
|
29
|
+
"@k03mad/eslint-config": "22.3.0",
|
|
30
30
|
"eslint": "8.57.0",
|
|
31
31
|
"husky": "9.0.11"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"lint": "npm run lint:eslint",
|
|
35
35
|
"lint:eslint": "eslint ./ --cache",
|
|
36
|
-
"clean": "
|
|
37
|
-
"clean:modules": "rm -rf ./node_modules || true",
|
|
38
|
-
"clean:eslint:cache": "rm -rf .eslintcache || true",
|
|
36
|
+
"clean": "rm -rf ./node_modules .eslintcache || true",
|
|
39
37
|
"setup": "npm run clean && npm run setup:pnpm",
|
|
40
38
|
"setup:pnpm": "npm i pnpm -g && pnpm i",
|
|
41
39
|
"prepare": "husky || true"
|