@platformatic/runtime 1.50.0 → 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/api-client.js CHANGED
@@ -170,10 +170,6 @@ class RuntimeApiClient extends EventEmitter {
170
170
 
171
171
  if (metrics === null) return null
172
172
 
173
- const entrypointDetails = await this.getEntrypointDetails()
174
- const entrypointConfig = await this.getServiceConfig(entrypointDetails.id)
175
- const entrypointMetricsPrefix = entrypointConfig.metrics?.prefix
176
-
177
173
  const cpuMetric = metrics.find(
178
174
  (metric) => metric.name === 'process_cpu_percent_usage'
179
175
  )
@@ -204,28 +200,27 @@ class RuntimeApiClient extends EventEmitter {
204
200
  let p95Value = 0
205
201
  let p99Value = 0
206
202
 
207
- if (entrypointMetricsPrefix) {
208
- const metricName = entrypointMetricsPrefix + 'http_request_all_summary_seconds'
209
- const httpLatencyMetrics = metrics.find((metric) => metric.name === metricName)
210
-
211
- p50Value = httpLatencyMetrics.values.find(
212
- (value) => value.labels.quantile === 0.5
213
- ).value || 0
214
- p90Value = httpLatencyMetrics.values.find(
215
- (value) => value.labels.quantile === 0.9
216
- ).value || 0
217
- p95Value = httpLatencyMetrics.values.find(
218
- (value) => value.labels.quantile === 0.95
219
- ).value || 0
220
- p99Value = httpLatencyMetrics.values.find(
221
- (value) => value.labels.quantile === 0.99
222
- ).value || 0
223
-
224
- p50Value = Math.round(p50Value * 1000)
225
- p90Value = Math.round(p90Value * 1000)
226
- p95Value = Math.round(p95Value * 1000)
227
- p99Value = Math.round(p99Value * 1000)
228
- }
203
+ const metricName = 'http_request_all_summary_seconds'
204
+ const httpLatencyMetrics =
205
+ metrics.find((metric) => metric.name === metricName)
206
+
207
+ p50Value = httpLatencyMetrics.values.find(
208
+ (value) => value.labels.quantile === 0.5
209
+ ).value || 0
210
+ p90Value = httpLatencyMetrics.values.find(
211
+ (value) => value.labels.quantile === 0.9
212
+ ).value || 0
213
+ p95Value = httpLatencyMetrics.values.find(
214
+ (value) => value.labels.quantile === 0.95
215
+ ).value || 0
216
+ p99Value = httpLatencyMetrics.values.find(
217
+ (value) => value.labels.quantile === 0.99
218
+ ).value || 0
219
+
220
+ p50Value = Math.round(p50Value * 1000)
221
+ p90Value = Math.round(p90Value * 1000)
222
+ p95Value = Math.round(p95Value * 1000)
223
+ p99Value = Math.round(p99Value * 1000)
229
224
 
230
225
  const cpu = cpuMetric.values[0].value
231
226
  const rss = rssMetric.values[0].value
package/lib/app.js CHANGED
@@ -4,7 +4,6 @@ const { dirname } = require('node:path')
4
4
  const { EventEmitter, once } = require('node:events')
5
5
  const { FileWatcher } = require('@platformatic/utils')
6
6
  const debounce = require('debounce')
7
- const { snakeCase } = require('change-case-all')
8
7
  const { buildServer } = require('./build-server')
9
8
  const { loadConfig } = require('./load-config')
10
9
  const errors = require('./errors')
@@ -275,12 +274,16 @@ class PlatformaticApp extends EventEmitter {
275
274
  (this.#hasManagementApi && configManager.current.metrics === undefined) ||
276
275
  configManager.current.metrics
277
276
  ) {
277
+ const labels = configManager.current.metrics?.labels || {}
278
278
  configManager.update({
279
279
  ...configManager.current,
280
280
  metrics: {
281
281
  server: 'hide',
282
282
  defaultMetrics: { enabled: this.appConfig.entrypoint },
283
- prefix: snakeCase(this.appConfig.id) + '_',
283
+ labels: {
284
+ serviceId: this.appConfig.id,
285
+ ...labels
286
+ },
284
287
  ...configManager.current.metrics
285
288
  }
286
289
  })
@@ -402,6 +402,12 @@ class RuntimeGenerator extends BaseGenerator {
402
402
  const newServicePackages = newService.plugins.map((meta) => meta.name)
403
403
  const pluginsToRemove = getArrayDifference(oldServicePackages, newServicePackages)
404
404
  pluginsToRemove.forEach((p) => delete currentRuntimeDependencies[p])
405
+ } else {
406
+ // add service to the generator
407
+ this.services.push({
408
+ name: newService.name,
409
+ service: serviceInstance
410
+ })
405
411
  }
406
412
  serviceInstance.setConfig(baseConfig)
407
413
  serviceInstance.setConfigFields(newService.fields)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "1.50.0",
3
+ "version": "1.52.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -34,8 +34,8 @@
34
34
  "typescript": "^5.4.2",
35
35
  "undici-oidc-interceptor": "^0.5.0",
36
36
  "why-is-node-running": "^2.2.2",
37
- "@platformatic/sql-graphql": "1.50.0",
38
- "@platformatic/sql-mapper": "1.50.0"
37
+ "@platformatic/sql-graphql": "1.52.0",
38
+ "@platformatic/sql-mapper": "1.52.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "@fastify/error": "^3.4.1",
@@ -63,14 +63,14 @@
63
63
  "undici": "^6.9.0",
64
64
  "why-is-node-running": "^2.2.2",
65
65
  "ws": "^8.16.0",
66
- "@platformatic/bus": "1.50.0",
67
- "@platformatic/composer": "1.50.0",
68
- "@platformatic/db": "1.50.0",
69
- "@platformatic/config": "1.50.0",
70
- "@platformatic/service": "1.50.0",
71
- "@platformatic/telemetry": "1.50.0",
72
- "@platformatic/generators": "1.50.0",
73
- "@platformatic/utils": "1.50.0"
66
+ "@platformatic/bus": "1.52.0",
67
+ "@platformatic/config": "1.52.0",
68
+ "@platformatic/db": "1.52.0",
69
+ "@platformatic/generators": "1.52.0",
70
+ "@platformatic/telemetry": "1.52.0",
71
+ "@platformatic/service": "1.52.0",
72
+ "@platformatic/composer": "1.52.0",
73
+ "@platformatic/utils": "1.52.0"
74
74
  },
75
75
  "standard": {
76
76
  "ignore": [