@platformatic/composer 2.71.0 → 2.71.1-alpha.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/metrics.js +12 -0
- package/lib/proxy.js +15 -2
- package/package.json +12 -11
- package/schema.json +1 -1
package/lib/metrics.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function initMetrics (prometheus) {
|
|
2
|
+
if (!prometheus?.registry || !prometheus?.client) return null
|
|
3
|
+
const { client, registry } = prometheus
|
|
4
|
+
|
|
5
|
+
return {
|
|
6
|
+
activeWsConnections: new client.Gauge({
|
|
7
|
+
name: 'active_ws_composer_connections',
|
|
8
|
+
help: 'Active Websocket composer connections in "@platformatic/composer"',
|
|
9
|
+
registers: [registry]
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
package/lib/proxy.js
CHANGED
|
@@ -5,6 +5,7 @@ const { ensureLoggableError } = require('@platformatic/utils')
|
|
|
5
5
|
const fp = require('fastify-plugin')
|
|
6
6
|
const { workerData } = require('node:worker_threads')
|
|
7
7
|
const { getGlobalDispatcher } = require('undici')
|
|
8
|
+
const { initMetrics } = require('./metrics')
|
|
8
9
|
|
|
9
10
|
const kITC = Symbol.for('plt.runtime.itc')
|
|
10
11
|
const kProxyRoute = Symbol('plt.composer.proxy.route')
|
|
@@ -52,6 +53,8 @@ async function resolveServiceProxyParameters (service) {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
let metrics
|
|
57
|
+
|
|
55
58
|
module.exports = fp(async function (app, opts) {
|
|
56
59
|
const meta = { proxies: {} }
|
|
57
60
|
const hostnameLessProxies = []
|
|
@@ -145,6 +148,10 @@ module.exports = fp(async function (app, opts) {
|
|
|
145
148
|
)
|
|
146
149
|
: null
|
|
147
150
|
|
|
151
|
+
if (!metrics) {
|
|
152
|
+
metrics = initMetrics(globalThis.platformatic?.prometheus)
|
|
153
|
+
}
|
|
154
|
+
|
|
148
155
|
const proxyOptions = {
|
|
149
156
|
prefix,
|
|
150
157
|
rewritePrefix,
|
|
@@ -155,8 +162,14 @@ module.exports = fp(async function (app, opts) {
|
|
|
155
162
|
wsUpstream: ws?.upstream ?? url ?? origin,
|
|
156
163
|
wsReconnect: ws?.reconnect,
|
|
157
164
|
wsHooks: {
|
|
158
|
-
onConnect:
|
|
159
|
-
|
|
165
|
+
onConnect: (...args) => {
|
|
166
|
+
metrics?.activeWsConnections?.inc()
|
|
167
|
+
ws?.hooks?.onConnect(...args)
|
|
168
|
+
},
|
|
169
|
+
onDisconnect: (...args) => {
|
|
170
|
+
metrics?.activeWsConnections?.dec()
|
|
171
|
+
ws?.hooks?.onDisconnect(...args)
|
|
172
|
+
},
|
|
160
173
|
onReconnect: ws?.hooks?.onReconnect,
|
|
161
174
|
onPong: ws?.hooks?.onPong,
|
|
162
175
|
onIncomingMessage: ws?.hooks?.onIncomingMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/composer",
|
|
3
|
-
"version": "2.71.0",
|
|
3
|
+
"version": "2.71.1-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"neostandard": "^0.12.0",
|
|
26
26
|
"openapi-schema-validator": "^12.1.3",
|
|
27
27
|
"pino-test": "^1.0.1",
|
|
28
|
+
"prom-client": "^15.1.2",
|
|
28
29
|
"self-cert": "^2.0.0",
|
|
29
30
|
"single-user-cache": "^1.0.1",
|
|
30
31
|
"split2": "^4.2.0",
|
|
@@ -32,9 +33,9 @@
|
|
|
32
33
|
"typescript": "^5.5.4",
|
|
33
34
|
"why-is-node-running": "2",
|
|
34
35
|
"ws": "^8.16.0",
|
|
35
|
-
"@platformatic/
|
|
36
|
-
"@platformatic/
|
|
37
|
-
"@platformatic/db": "2.71.0"
|
|
36
|
+
"@platformatic/client": "2.71.1-alpha.0",
|
|
37
|
+
"@platformatic/config": "2.71.1-alpha.0",
|
|
38
|
+
"@platformatic/db": "2.71.1-alpha.0"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"@fastify/error": "^4.0.0",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@fastify/view": "^10.0.1",
|
|
46
47
|
"@platformatic/fastify-openapi-glue": "^5.1.0",
|
|
47
48
|
"@platformatic/graphql-composer": "^0.10.0",
|
|
48
|
-
"@scalar/fastify-api-reference": "1.
|
|
49
|
+
"@scalar/fastify-api-reference": "1.32.4",
|
|
49
50
|
"ajv": "^8.12.0",
|
|
50
51
|
"commist": "^3.2.0",
|
|
51
52
|
"console-table-printer": "^2.12.0",
|
|
@@ -68,12 +69,12 @@
|
|
|
68
69
|
"rfdc": "^1.3.1",
|
|
69
70
|
"semgrator": "^0.3.0",
|
|
70
71
|
"undici": "^7.0.0",
|
|
71
|
-
"@platformatic/
|
|
72
|
-
"@platformatic/scalar-theme": "2.71.0",
|
|
73
|
-
"@platformatic/
|
|
74
|
-
"@platformatic/service": "2.71.0",
|
|
75
|
-
"@platformatic/telemetry": "2.71.0",
|
|
76
|
-
"@platformatic/
|
|
72
|
+
"@platformatic/generators": "2.71.1-alpha.0",
|
|
73
|
+
"@platformatic/scalar-theme": "2.71.1-alpha.0",
|
|
74
|
+
"@platformatic/utils": "^2.71.1-alpha.0",
|
|
75
|
+
"@platformatic/service": "2.71.1-alpha.0",
|
|
76
|
+
"@platformatic/telemetry": "2.71.1-alpha.0",
|
|
77
|
+
"@platformatic/config": "2.71.1-alpha.0"
|
|
77
78
|
},
|
|
78
79
|
"scripts": {
|
|
79
80
|
"test": "pnpm run lint && borp -T --timeout=1200000 -c 1 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/composer/2.71.0.json",
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/composer/2.71.1-alpha.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Composer",
|
|
5
5
|
"type": "object",
|