@platformatic/runtime 3.2.1 → 3.3.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
@@ -223,6 +223,10 @@ export type PlatformaticRuntimeConfig = {
223
223
  labels?: {
224
224
  [k: string]: string;
225
225
  };
226
+ /**
227
+ * The label name to use for the application identifier in metrics (e.g., applicationId, serviceId)
228
+ */
229
+ applicationLabel?: string;
226
230
  readiness?:
227
231
  | boolean
228
232
  | {
package/lib/runtime.js CHANGED
@@ -97,6 +97,7 @@ export class Runtime extends EventEmitter {
97
97
  #managementApi
98
98
  #prometheusServer
99
99
  #inspectorServer
100
+ #metricsLabelName
100
101
 
101
102
  #applicationsConfigsPatches
102
103
  #workers
@@ -161,7 +162,12 @@ export class Runtime extends EventEmitter {
161
162
  }
162
163
 
163
164
  if (config.metrics) {
165
+ // Use the configured application label name for metrics (defaults to 'applicationId')
166
+ this.#metricsLabelName = config.metrics.applicationLabel || 'applicationId'
164
167
  this.#prometheusServer = await startPrometheusServer(this, config.metrics)
168
+ } else {
169
+ // Default to applicationId if metrics are not configured
170
+ this.#metricsLabelName = 'applicationId'
165
171
  }
166
172
 
167
173
  // Create the logger
@@ -913,10 +919,11 @@ export class Runtime extends EventEmitter {
913
919
  if (!values || values.length === 0) continue
914
920
 
915
921
  const labels = values[0].labels
916
- const applicationId = labels?.applicationId
922
+ // Use the configured label name (serviceId for v2 compatibility, applicationId for v3+)
923
+ const applicationId = labels?.[this.#metricsLabelName]
917
924
 
918
925
  if (!applicationId) {
919
- throw new Error('Missing applicationId label in metrics')
926
+ throw new Error(`Missing ${this.#metricsLabelName} label in metrics`)
920
927
  }
921
928
 
922
929
  let applicationMetrics = applicationsMetrics[applicationId]
@@ -166,13 +166,21 @@ async function main () {
166
166
  }
167
167
 
168
168
  // Create the application
169
+ // Add idLabel to metrics config to determine which label name to use (defaults to applicationId)
170
+ const metricsConfig = config.metrics
171
+ ? {
172
+ ...config.metrics,
173
+ idLabel: config.metrics.applicationLabel || 'applicationId'
174
+ }
175
+ : config.metrics
176
+
169
177
  const controller = new Controller(
170
178
  application,
171
179
  workerData.worker.count > 1 ? workerData.worker.index : undefined,
172
180
  application.telemetry,
173
181
  config.logger,
174
182
  serverConfig,
175
- config.metrics,
183
+ metricsConfig,
176
184
  !!config.managementApi,
177
185
  !!config.watch
178
186
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,14 +34,14 @@
34
34
  "typescript": "^5.5.4",
35
35
  "undici-oidc-interceptor": "^0.5.0",
36
36
  "why-is-node-running": "^2.2.2",
37
- "@platformatic/composer": "3.2.1",
38
- "@platformatic/db": "3.2.1",
39
- "@platformatic/gateway": "3.2.1",
40
- "@platformatic/node": "3.2.1",
41
- "@platformatic/service": "3.2.1",
42
- "@platformatic/sql-graphql": "3.2.1",
43
- "@platformatic/sql-mapper": "3.2.1",
44
- "@platformatic/wattpm-pprof-capture": "3.2.1"
37
+ "@platformatic/composer": "3.3.0",
38
+ "@platformatic/db": "3.3.0",
39
+ "@platformatic/gateway": "3.3.0",
40
+ "@platformatic/node": "3.3.0",
41
+ "@platformatic/service": "3.3.0",
42
+ "@platformatic/sql-graphql": "3.3.0",
43
+ "@platformatic/wattpm-pprof-capture": "3.3.0",
44
+ "@platformatic/sql-mapper": "3.3.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@fastify/accepts": "^5.0.0",
@@ -71,12 +71,12 @@
71
71
  "undici": "^7.0.0",
72
72
  "undici-thread-interceptor": "^0.14.0",
73
73
  "ws": "^8.16.0",
74
- "@platformatic/basic": "3.2.1",
75
- "@platformatic/generators": "3.2.1",
76
- "@platformatic/foundation": "3.2.1",
77
- "@platformatic/itc": "3.2.1",
78
- "@platformatic/telemetry": "3.2.1",
79
- "@platformatic/metrics": "3.2.1"
74
+ "@platformatic/basic": "3.3.0",
75
+ "@platformatic/foundation": "3.3.0",
76
+ "@platformatic/generators": "3.3.0",
77
+ "@platformatic/itc": "3.3.0",
78
+ "@platformatic/metrics": "3.3.0",
79
+ "@platformatic/telemetry": "3.3.0"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.2.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.3.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -1585,6 +1585,11 @@
1585
1585
  "type": "string"
1586
1586
  }
1587
1587
  },
1588
+ "applicationLabel": {
1589
+ "type": "string",
1590
+ "default": "applicationId",
1591
+ "description": "The label name to use for the application identifier in metrics (e.g., applicationId, serviceId)"
1592
+ },
1588
1593
  "readiness": {
1589
1594
  "anyOf": [
1590
1595
  {