@platformatic/service 1.46.0 → 1.48.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/config.d.ts CHANGED
@@ -80,7 +80,9 @@ export interface PlatformaticService {
80
80
  requestIdLogLabel?: string;
81
81
  jsonShorthand?: boolean;
82
82
  trustProxy?: boolean | string | string[] | number;
83
+ http2?: boolean;
83
84
  https?: {
85
+ allowHTTP1?: boolean;
84
86
  key:
85
87
  | string
86
88
  | {
@@ -154,6 +156,9 @@ export interface PlatformaticService {
154
156
  username: string;
155
157
  password: string;
156
158
  };
159
+ labels?: {
160
+ [k: string]: string;
161
+ };
157
162
  };
158
163
  telemetry?: OpenTelemetry;
159
164
  watch?:
@@ -12,7 +12,10 @@ async function setupGraphQL (app, opts) {
12
12
  opts = {}
13
13
  }
14
14
  const graphqlOptions = deepmerge({
15
- graphiql: true
15
+ graphiql: true,
16
+ additionalRouteOptions: {
17
+ schema: { hide: true }
18
+ }
16
19
  }, opts)
17
20
 
18
21
  app.register(mercurius, graphqlOptions)
@@ -7,22 +7,43 @@ const fastify = require('fastify')
7
7
  const fp = require('fastify-plugin')
8
8
 
9
9
  const metricsPlugin = fp(async function (app, opts = {}) {
10
+ const promClient = require('prom-client')
11
+
12
+ const register = new promClient.Registry()
13
+
10
14
  const defaultMetrics = opts.defaultMetrics ?? { enabled: true }
11
15
  const prefix = opts.prefix ?? ''
12
16
 
17
+ if (opts.labels) {
18
+ const labels = opts.labels ?? {}
19
+ register.setDefaultLabels(labels)
20
+ }
21
+
13
22
  app.register(require('fastify-metrics'), {
14
- defaultMetrics: defaultMetrics || { enabled: true },
23
+ defaultMetrics: {
24
+ ...defaultMetrics,
25
+ register
26
+ },
15
27
  endpoint: null,
16
28
  name: 'metrics',
17
29
  clearRegisterOnInit: false,
30
+ promClient: {
31
+ ...promClient,
32
+ register
33
+ },
18
34
  routeMetrics: {
19
35
  enabled: true,
36
+ customLabels: {
37
+ telemetry_id: (req) => req.headers['x-telemetry-id'] ?? 'unknown'
38
+ },
20
39
  overrides: {
21
40
  histogram: {
22
- name: prefix + 'http_request_duration_seconds'
41
+ name: prefix + 'http_request_duration_seconds',
42
+ registers: [register]
23
43
  },
24
44
  summary: {
25
- name: prefix + 'http_request_summary_seconds'
45
+ name: prefix + 'http_request_summary_seconds',
46
+ registers: [register]
26
47
  }
27
48
  }
28
49
  }
@@ -34,8 +55,10 @@ const metricsPlugin = fp(async function (app, opts = {}) {
34
55
  help: 'request duration in seconds summary for all requests',
35
56
  collect: () => {
36
57
  process.nextTick(() => httpLatencyMetric.reset())
37
- }
58
+ },
59
+ registers: [register]
38
60
  })
61
+
39
62
  const ignoredMethods = ['HEAD', 'OPTIONS', 'TRACE', 'CONNECT']
40
63
  const timers = new WeakMap()
41
64
  app.addHook('onRequest', async (req) => {
@@ -66,7 +89,8 @@ const metricsPlugin = fp(async function (app, opts = {}) {
66
89
  const result = eventLoopUtilization(endELU, startELU).utilization
67
90
  eluMetric.set(result)
68
91
  startELU = endELU
69
- }
92
+ },
93
+ registers: [register]
70
94
  })
71
95
  app.metrics.client.register.registerMetric(eluMetric)
72
96
 
@@ -98,7 +122,8 @@ const metricsPlugin = fp(async function (app, opts = {}) {
98
122
 
99
123
  previousIdleTime = idleTime
100
124
  previousTotalTime = totalTime
101
- }
125
+ },
126
+ registers: [register]
102
127
  })
103
128
  app.metrics.client.register.registerMetric(cpuMetric)
104
129
  })
package/lib/schema.js CHANGED
@@ -293,9 +293,15 @@ const server = {
293
293
  { type: 'integer' }
294
294
  ]
295
295
  },
296
+ http2: {
297
+ type: 'boolean'
298
+ },
296
299
  https: {
297
300
  type: 'object',
298
301
  properties: {
302
+ allowHTTP1: {
303
+ type: 'boolean'
304
+ },
299
305
  key: {
300
306
  anyOf: [
301
307
  {
@@ -577,6 +583,10 @@ const metrics = {
577
583
  },
578
584
  additionalProperties: false,
579
585
  required: ['username', 'password']
586
+ },
587
+ labels: {
588
+ type: 'object',
589
+ additionalProperties: { type: 'string' }
580
590
  }
581
591
  },
582
592
  additionalProperties: false
package/lib/start.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const { readFile } = require('fs/promises')
4
4
  const close = require('close-with-grace')
5
+ const { Bus } = require('@platformatic/bus')
5
6
  const { loadConfig, ConfigManager, printConfigValidationErrors, printAndExitLoadConfigError } = require('@platformatic/config')
6
7
  const { addLoggerToTheConfig, isDocker } = require('./utils.js')
7
8
  const { restartable } = require('@fastify/restartable')
@@ -60,7 +61,7 @@ async function buildServer (options, app) {
60
61
  }
61
62
  fastifyOptions.genReqId = function (req) { return randomUUID() }
62
63
  const root = fastify(fastifyOptions)
63
- root.decorate('platformatic', { configManager, config })
64
+ root.decorate('platformatic', { configManager, config, bus: new Bus(options.id) })
64
65
  await root.register(app)
65
66
  if (!root.hasRoute({ url: '/', method: 'GET' })) {
66
67
  await root.register(require('./root-endpoint'), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "1.46.0",
3
+ "version": "1.48.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -44,7 +44,7 @@
44
44
  "@fastify/cors": "^9.0.1",
45
45
  "@fastify/deepmerge": "^1.3.0",
46
46
  "@fastify/error": "^3.4.1",
47
- "@fastify/restartable": "^2.2.0",
47
+ "@fastify/restartable": "^2.3.1",
48
48
  "@fastify/static": "^7.0.1",
49
49
  "@fastify/swagger": "^8.14.0",
50
50
  "@fastify/under-pressure": "^8.3.0",
@@ -62,7 +62,7 @@
62
62
  "env-schema": "^5.2.1",
63
63
  "es-main": "^1.3.0",
64
64
  "execa": "^8.0.1",
65
- "fastify": "^4.26.2",
65
+ "fastify": "^4.28.1",
66
66
  "fastify-metrics": "^11.0.0",
67
67
  "fastify-openapi-glue": "^4.4.3",
68
68
  "fastify-plugin": "^4.5.1",
@@ -75,16 +75,18 @@
75
75
  "ora": "^6.3.1",
76
76
  "pino": "^8.19.0",
77
77
  "pino-pretty": "^11.0.0",
78
+ "prom-client": "^15.1.2",
78
79
  "rfdc": "^1.3.1",
79
80
  "semgrator": "^0.3.0",
80
81
  "undici": "^6.9.0",
81
- "@platformatic/client": "1.46.0",
82
- "@platformatic/generators": "1.46.0",
83
- "@platformatic/authenticate": "1.46.0",
84
- "@platformatic/config": "1.46.0",
85
- "@platformatic/scalar-theme": "1.46.0",
86
- "@platformatic/telemetry": "1.46.0",
87
- "@platformatic/utils": "1.46.0"
82
+ "@platformatic/authenticate": "1.48.0",
83
+ "@platformatic/bus": "1.48.0",
84
+ "@platformatic/client": "1.48.0",
85
+ "@platformatic/generators": "1.48.0",
86
+ "@platformatic/scalar-theme": "1.48.0",
87
+ "@platformatic/config": "1.48.0",
88
+ "@platformatic/utils": "1.48.0",
89
+ "@platformatic/telemetry": "1.48.0"
88
90
  },
89
91
  "standard": {
90
92
  "ignore": [
package/schema.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "$id": "https://platformatic.dev/schemas/v1.46.0/service",
3
- "version": "1.46.0",
2
+ "$id": "https://platformatic.dev/schemas/v1.48.0/service",
3
+ "version": "1.48.0",
4
4
  "title": "Platformatic Service",
5
5
  "type": "object",
6
6
  "properties": {
@@ -247,9 +247,15 @@
247
247
  }
248
248
  ]
249
249
  },
250
+ "http2": {
251
+ "type": "boolean"
252
+ },
250
253
  "https": {
251
254
  "type": "object",
252
255
  "properties": {
256
+ "allowHTTP1": {
257
+ "type": "boolean"
258
+ },
253
259
  "key": {
254
260
  "anyOf": [
255
261
  {
@@ -647,6 +653,12 @@
647
653
  "username",
648
654
  "password"
649
655
  ]
656
+ },
657
+ "labels": {
658
+ "type": "object",
659
+ "additionalProperties": {
660
+ "type": "string"
661
+ }
650
662
  }
651
663
  },
652
664
  "additionalProperties": false