forked from siimon/prom-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.js
40 lines (34 loc) · 821 Bytes
/
version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const Gauge = require('../gauge');
const version = process.version;
const versionSegments = version
.slice(1)
.split('.')
.map(Number);
const NODE_VERSION_INFO = 'nodejs_version_info';
module.exports = (registry, config = {}) => {
const namePrefix = config.prefix ? config.prefix : '';
const nodeVersionGauge = new Gauge({
name: namePrefix + NODE_VERSION_INFO,
help: 'Node.js version info.',
labelNames: ['version', 'major', 'minor', 'patch'],
registers: registry ? [registry] : undefined,
aggregator: 'first'
});
let isSet = false;
return () => {
if (isSet) {
return;
}
nodeVersionGauge
.labels(
version,
versionSegments[0],
versionSegments[1],
versionSegments[2]
)
.set(1);
isSet = true;
};
};
module.exports.metricNames = [NODE_VERSION_INFO];