@platformatic/service 1.51.8 → 1.52.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/lib/plugins/metrics.js +10 -6
- package/package.json +8 -8
- package/schema.json +2 -2
package/lib/plugins/metrics.js
CHANGED
|
@@ -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:
|
|
44
|
+
name: 'http_request_duration_seconds',
|
|
42
45
|
registers: [register]
|
|
43
46
|
},
|
|
44
47
|
summary: {
|
|
45
|
-
name:
|
|
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:
|
|
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 ||
|
|
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.
|
|
3
|
+
"version": "1.52.0",
|
|
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.
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/
|
|
87
|
-
"@platformatic/
|
|
88
|
-
"@platformatic/
|
|
82
|
+
"@platformatic/bus": "1.52.0",
|
|
83
|
+
"@platformatic/client": "1.52.0",
|
|
84
|
+
"@platformatic/config": "1.52.0",
|
|
85
|
+
"@platformatic/utils": "1.52.0",
|
|
86
|
+
"@platformatic/generators": "1.52.0",
|
|
87
|
+
"@platformatic/telemetry": "1.52.0",
|
|
88
|
+
"@platformatic/scalar-theme": "1.52.0"
|
|
89
89
|
},
|
|
90
90
|
"standard": {
|
|
91
91
|
"ignore": [
|
package/schema.json
CHANGED