@platformatic/metrics 3.0.6 → 3.2.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/index.js +2 -16
- package/package.json +2 -5
package/index.js
CHANGED
|
@@ -37,22 +37,8 @@ export async function collectThreadCpuMetrics (registry) {
|
|
|
37
37
|
return
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
let threadCpuUsage
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
// We need until we switch to 22 as thread-cpu-usage is ESM
|
|
44
|
-
const res = await import('thread-cpu-usage')
|
|
45
|
-
threadCpuUsage = res.threadCpuUsage
|
|
46
|
-
} catch {
|
|
47
|
-
process.emitWarning('thread-cpu-usage not available')
|
|
48
|
-
// We ignore the loading error, as this might
|
|
49
|
-
// happen if the library has failed to compile
|
|
50
|
-
// on this platform.
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
40
|
let lastSample = process.hrtime.bigint()
|
|
55
|
-
let lastUsage = threadCpuUsage()
|
|
41
|
+
let lastUsage = process.threadCpuUsage()
|
|
56
42
|
|
|
57
43
|
const threadCpuUserUsageCounterMetric = new Counter({
|
|
58
44
|
name: 'thread_cpu_user_system_seconds_total',
|
|
@@ -78,7 +64,7 @@ export async function collectThreadCpuMetrics (registry) {
|
|
|
78
64
|
// Use this one metric's `collect` to set all metrics' values.
|
|
79
65
|
collect () {
|
|
80
66
|
const newSample = process.hrtime.bigint()
|
|
81
|
-
const newUsage = threadCpuUsage()
|
|
67
|
+
const newUsage = process.threadCpuUsage()
|
|
82
68
|
const user = newUsage.user - lastUsage.user
|
|
83
69
|
const system = newUsage.system - lastUsage.system
|
|
84
70
|
const elapsed = Number(newSample - lastSample)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/metrics",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Platformatic Capability Metrics",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,16 +18,13 @@
|
|
|
18
18
|
"@platformatic/http-metrics": "^0.2.1",
|
|
19
19
|
"prom-client": "^15.1.2"
|
|
20
20
|
},
|
|
21
|
-
"optionalDependencies": {
|
|
22
|
-
"thread-cpu-usage": "^0.2.0"
|
|
23
|
-
},
|
|
24
21
|
"devDependencies": {
|
|
25
22
|
"cleaner-spec-reporter": "^0.5.0",
|
|
26
23
|
"eslint": "9",
|
|
27
24
|
"neostandard": "^0.12.0"
|
|
28
25
|
},
|
|
29
26
|
"engines": {
|
|
30
|
-
"node": ">=22.
|
|
27
|
+
"node": ">=22.19.0"
|
|
31
28
|
},
|
|
32
29
|
"scripts": {
|
|
33
30
|
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js",
|