@platformatic/service 1.51.8 → 1.52.1

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.
@@ -12,10 +12,12 @@ const metricsPlugin = fp(async function (app, opts = {}) {
12
12
  const register = new promClient.Registry()
13
13
 
14
14
  const defaultMetrics = opts.defaultMetrics ?? { enabled: true }
15
- const prefix = opts.prefix ?? ''
16
15
 
17
- if (opts.labels) {
16
+ if (opts.labels || opts.prefix) {
18
17
  const labels = opts.labels ?? {}
18
+ if (opts.prefix) {
19
+ labels.prefix = opts.prefix
20
+ }
19
21
  register.setDefaultLabels(labels)
20
22
  }
21
23
 
@@ -34,15 +36,16 @@ const metricsPlugin = fp(async function (app, opts = {}) {
34
36
  routeMetrics: {
35
37
  enabled: true,
36
38
  customLabels: {
39
+ // TODO: check if this is set in prom
37
40
  telemetry_id: (req) => req.headers['x-telemetry-id'] ?? 'unknown'
38
41
  },
39
42
  overrides: {
40
43
  histogram: {
41
- name: prefix + 'http_request_duration_seconds',
44
+ name: 'http_request_duration_seconds',
42
45
  registers: [register]
43
46
  },
44
47
  summary: {
45
- name: prefix + 'http_request_summary_seconds',
48
+ name: 'http_request_summary_seconds',
46
49
  registers: [register]
47
50
  }
48
51
  }
@@ -51,7 +54,7 @@ const metricsPlugin = fp(async function (app, opts = {}) {
51
54
 
52
55
  app.register(fp(async (app) => {
53
56
  const httpLatencyMetric = new app.metrics.client.Summary({
54
- name: prefix + 'http_request_all_summary_seconds',
57
+ name: 'http_request_all_summary_seconds',
55
58
  help: 'request duration in seconds summary for all requests',
56
59
  collect: () => {
57
60
  process.nextTick(() => httpLatencyMetric.reset())
@@ -130,9 +133,10 @@ const metricsPlugin = fp(async function (app, opts = {}) {
130
133
  }
131
134
 
132
135
  function cleanMetrics () {
136
+ const httpMetrics = ['http_request_duration_seconds', 'http_request_summary_seconds', 'http_request_all_summary_seconds']
133
137
  const metrics = app.metrics.client.register._metrics
134
138
  for (const metricName in metrics) {
135
- if (defaultMetrics.enabled || metricName.startsWith(prefix)) {
139
+ if (defaultMetrics.enabled || httpMetrics.includes(metricName)) {
136
140
  delete metrics[metricName]
137
141
  }
138
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "1.51.8",
3
+ "version": "1.52.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -79,13 +79,13 @@
79
79
  "rfdc": "^1.3.1",
80
80
  "semgrator": "^0.3.0",
81
81
  "undici": "^6.9.0",
82
- "@platformatic/bus": "1.51.8",
83
- "@platformatic/config": "1.51.8",
84
- "@platformatic/client": "1.51.8",
85
- "@platformatic/generators": "1.51.8",
86
- "@platformatic/utils": "1.51.8",
87
- "@platformatic/scalar-theme": "1.51.8",
88
- "@platformatic/telemetry": "1.51.8"
82
+ "@platformatic/bus": "1.52.1",
83
+ "@platformatic/config": "1.52.1",
84
+ "@platformatic/generators": "1.52.1",
85
+ "@platformatic/scalar-theme": "1.52.1",
86
+ "@platformatic/client": "1.52.1",
87
+ "@platformatic/telemetry": "1.52.1",
88
+ "@platformatic/utils": "1.52.1"
89
89
  },
90
90
  "standard": {
91
91
  "ignore": [
package/schema.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "$id": "https://platformatic.dev/schemas/v1.51.8/service",
3
- "version": "1.51.8",
2
+ "$id": "https://platformatic.dev/schemas/v1.52.1/service",
3
+ "version": "1.52.1",
4
4
  "title": "Platformatic Service",
5
5
  "type": "object",
6
6
  "properties": {