@platformatic/metrics 2.23.0 → 2.25.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 +8 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
const os = require('node:os')
|
|
4
4
|
const { eventLoopUtilization } = require('node:perf_hooks').performance
|
|
5
|
-
const
|
|
5
|
+
const client = require('prom-client')
|
|
6
6
|
const collectHttpMetrics = require('@platformatic/http-metrics')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const { Registry, Gauge, Counter, collectDefaultMetrics } = client
|
|
9
|
+
|
|
10
|
+
async function collectMetrics (serviceId, workerId, metricsConfig = {}, registry = undefined) {
|
|
11
|
+
if (!registry) {
|
|
12
|
+
registry = new Registry()
|
|
13
|
+
}
|
|
10
14
|
|
|
11
15
|
const httpRequestCallbacks = []
|
|
12
16
|
const httpResponseCallbacks = []
|
|
@@ -171,4 +175,4 @@ function collectEluMetric (register) {
|
|
|
171
175
|
register.registerMetric(cpuMetric)
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
module.exports = { collectMetrics }
|
|
178
|
+
module.exports = { collectMetrics, client }
|