@platformatic/metrics 2.22.0 → 2.24.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 +8 -4
  2. package/package.json +2 -2
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 { Registry, Gauge, Counter, collectDefaultMetrics } = require('prom-client')
5
+ const client = require('prom-client')
6
6
  const collectHttpMetrics = require('@platformatic/http-metrics')
7
7
 
8
- async function collectMetrics (serviceId, workerId, metricsConfig = {}) {
9
- const registry = new Registry()
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 }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/metrics",
3
- "version": "2.22.0",
3
+ "version": "2.24.0",
4
4
  "description": "Platformatic Stackable Metrics",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -22,7 +22,7 @@
22
22
  "devDependencies": {
23
23
  "borp": "^0.19.0",
24
24
  "eslint": "9",
25
- "neostandard": "^0.11.1"
25
+ "neostandard": "^0.12.0"
26
26
  },
27
27
  "scripts": {
28
28
  "test": "npm run lint",