@platformatic/service 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/lib/stackable.js +16 -12
- package/package.json +9 -9
- package/schema.json +2 -2
package/lib/stackable.js
CHANGED
|
@@ -6,7 +6,7 @@ const { pathToFileURL } = require('node:url')
|
|
|
6
6
|
const { workerData } = require('node:worker_threads')
|
|
7
7
|
const { printSchema } = require('graphql')
|
|
8
8
|
const pino = require('pino')
|
|
9
|
-
const { collectMetrics } = require('@platformatic/metrics')
|
|
9
|
+
const { client, collectMetrics } = require('@platformatic/metrics')
|
|
10
10
|
const httpMetrics = require('@platformatic/fastify-http-metrics')
|
|
11
11
|
const { extractTypeScriptCompileOptionsFromConfig } = require('./compile')
|
|
12
12
|
const { compile } = require('@platformatic/ts-compiler')
|
|
@@ -19,7 +19,7 @@ class ServiceStackable {
|
|
|
19
19
|
this.app = null
|
|
20
20
|
this._init = options.init
|
|
21
21
|
this.stackable = options.stackable
|
|
22
|
-
this.metricsRegistry =
|
|
22
|
+
this.metricsRegistry = new client.Registry()
|
|
23
23
|
|
|
24
24
|
this.configManager = options.configManager
|
|
25
25
|
this.context = options.context ?? {}
|
|
@@ -52,7 +52,8 @@ class ServiceStackable {
|
|
|
52
52
|
setConnectionString: this.setConnectionString.bind(this),
|
|
53
53
|
setBasePath: this.setBasePath.bind(this),
|
|
54
54
|
runtimeBasePath: this.runtimeConfig?.basePath ?? null,
|
|
55
|
-
invalidateHttpCache: this.#invalidateHttpCache.bind(this)
|
|
55
|
+
invalidateHttpCache: this.#invalidateHttpCache.bind(this),
|
|
56
|
+
prometheus: { client, registry: this.metricsRegistry }
|
|
56
57
|
})
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -138,7 +139,7 @@ class ServiceStackable {
|
|
|
138
139
|
tcp: !!this.app?.url,
|
|
139
140
|
url: this.app?.url
|
|
140
141
|
},
|
|
141
|
-
connectionStrings: [this.connectionString]
|
|
142
|
+
connectionStrings: [this.connectionString]
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -182,19 +183,22 @@ class ServiceStackable {
|
|
|
182
183
|
const metricsConfig = this.context.metricsConfig
|
|
183
184
|
|
|
184
185
|
if (metricsConfig !== false) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
await collectMetrics(
|
|
187
|
+
this.serviceId,
|
|
188
|
+
this.workerId,
|
|
189
|
+
{
|
|
190
|
+
defaultMetrics: true,
|
|
191
|
+
httpMetrics: false,
|
|
192
|
+
...metricsConfig
|
|
193
|
+
},
|
|
194
|
+
this.metricsRegistry
|
|
195
|
+
)
|
|
196
|
+
|
|
191
197
|
this.#setHttpMetrics()
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
async getMetrics ({ format }) {
|
|
196
|
-
if (!this.metricsRegistry) return null
|
|
197
|
-
|
|
198
202
|
return format === 'json' ? await this.metricsRegistry.getMetricsAsJSON() : await this.metricsRegistry.metrics()
|
|
199
203
|
}
|
|
200
204
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -76,14 +76,14 @@
|
|
|
76
76
|
"rfdc": "^1.3.1",
|
|
77
77
|
"semgrator": "^0.3.0",
|
|
78
78
|
"undici": "^7.0.0",
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/scalar-theme": "2.
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/client": "2.25.0",
|
|
80
|
+
"@platformatic/config": "2.25.0",
|
|
81
|
+
"@platformatic/generators": "2.25.0",
|
|
82
|
+
"@platformatic/scalar-theme": "2.25.0",
|
|
83
|
+
"@platformatic/telemetry": "2.25.0",
|
|
84
|
+
"@platformatic/ts-compiler": "2.25.0",
|
|
85
|
+
"@platformatic/utils": "2.25.0",
|
|
86
|
+
"@platformatic/metrics": "2.25.0"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.
|
|
3
|
-
"version": "2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.25.0.json",
|
|
3
|
+
"version": "2.25.0",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|