@platformatic/service 2.5.4 → 2.5.5-alpha.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.
- package/lib/stackable.js +25 -10
- package/package.json +9 -8
- package/schema.json +2 -2
package/lib/stackable.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { dirname } = require('node:path')
|
|
4
4
|
const { printSchema } = require('graphql')
|
|
5
5
|
const pino = require('pino')
|
|
6
|
+
const { collectMetrics } = require('@platformatic/metrics')
|
|
6
7
|
const httpMetrics = require('@platformatic/fastify-http-metrics')
|
|
7
8
|
const { extractTypeScriptCompileOptionsFromConfig } = require('./compile')
|
|
8
9
|
const { compile } = require('@platformatic/ts-compiler')
|
|
@@ -42,10 +43,7 @@ class ServiceStackable {
|
|
|
42
43
|
|
|
43
44
|
if (this.app === null) {
|
|
44
45
|
this.app = await this._init()
|
|
45
|
-
|
|
46
|
-
if (this.metricsRegistry) {
|
|
47
|
-
this.#setHttpMetrics()
|
|
48
|
-
}
|
|
46
|
+
await this.#collectMetrics()
|
|
49
47
|
}
|
|
50
48
|
return this.app
|
|
51
49
|
}
|
|
@@ -153,15 +151,32 @@ class ServiceStackable {
|
|
|
153
151
|
return this.app.graphql ? printSchema(this.app.graphql.schema) : null
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
// This method is not a part of Stackable interface because we need to register
|
|
155
|
+
// fastify metrics before the server is started.
|
|
156
|
+
async #collectMetrics () {
|
|
157
|
+
const metricsConfig = this.context.metricsConfig
|
|
158
|
+
if (metricsConfig !== false) {
|
|
159
|
+
const { registry } = await collectMetrics(
|
|
160
|
+
this.context.serviceId,
|
|
161
|
+
{
|
|
162
|
+
defaultMetrics: true,
|
|
163
|
+
httpMetrics: false,
|
|
164
|
+
...metricsConfig
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
this.metricsRegistry = registry
|
|
168
|
+
this.#setHttpMetrics()
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
171
|
|
|
172
|
+
async getMetrics ({ format }) {
|
|
173
|
+
if (!this.metricsRegistry) return null
|
|
174
|
+
|
|
175
|
+
return format === 'json'
|
|
176
|
+
? await this.metricsRegistry.getMetricsAsJSON()
|
|
177
|
+
: await this.metricsRegistry.metrics()
|
|
178
|
+
}
|
|
179
|
+
|
|
165
180
|
async inject (injectParams) {
|
|
166
181
|
await this.init()
|
|
167
182
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.5-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -76,13 +76,14 @@
|
|
|
76
76
|
"rfdc": "^1.3.1",
|
|
77
77
|
"semgrator": "^0.3.0",
|
|
78
78
|
"undici": "^6.9.0",
|
|
79
|
-
"@platformatic/client": "2.5.
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
79
|
+
"@platformatic/client": "2.5.5-alpha.1",
|
|
80
|
+
"@platformatic/config": "2.5.5-alpha.1",
|
|
81
|
+
"@platformatic/metrics": "2.5.5-alpha.1",
|
|
82
|
+
"@platformatic/generators": "2.5.5-alpha.1",
|
|
83
|
+
"@platformatic/scalar-theme": "2.5.5-alpha.1",
|
|
84
|
+
"@platformatic/telemetry": "2.5.5-alpha.1",
|
|
85
|
+
"@platformatic/ts-compiler": "2.5.5-alpha.1",
|
|
86
|
+
"@platformatic/utils": "2.5.5-alpha.1"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
89
|
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=180000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.5.
|
|
3
|
-
"version": "2.5.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.5.5-alpha.1.json",
|
|
3
|
+
"version": "2.5.5-alpha.1",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|