@platformatic/metrics 3.0.5 → 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.
Files changed (2) hide show
  1. package/index.js +2 -16
  2. package/package.json +2 -2
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.5",
3
+ "version": "3.1.0",
4
4
  "description": "Platformatic Capability Metrics",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "neostandard": "^0.12.0"
28
28
  },
29
29
  "engines": {
30
- "node": ">=22.18.0"
30
+ "node": ">=22.19.0"
31
31
  },
32
32
  "scripts": {
33
33
  "test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js",