@platformatic/watt-extra 1.15.0 → 1.16.0-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/watt.js +6 -1
- package/package.json +1 -1
- package/test/init.test.js +2 -0
- package/test/metrics.test.js +9 -1
- package/test/patch-config.test.js +12 -0
package/lib/watt.js
CHANGED
|
@@ -126,7 +126,8 @@ class Watt {
|
|
|
126
126
|
...currentMetrics,
|
|
127
127
|
labels: {
|
|
128
128
|
...currentMetrics.labels,
|
|
129
|
-
applicationId: instanceConfig.applicationId
|
|
129
|
+
applicationId: instanceConfig.applicationId,
|
|
130
|
+
...(instanceConfig.deploymentVersion ? { deploymentVersion: instanceConfig.deploymentVersion } : {})
|
|
130
131
|
},
|
|
131
132
|
applicationLabel: instanceConfig.applicationMetricsLabel ?? currentMetrics.applicationLabel
|
|
132
133
|
}
|
|
@@ -223,6 +224,10 @@ class Watt {
|
|
|
223
224
|
if (applicationId) {
|
|
224
225
|
labels.applicationId = applicationId
|
|
225
226
|
}
|
|
227
|
+
const deploymentVersion = this.#instanceConfig?.deploymentVersion
|
|
228
|
+
if (deploymentVersion) {
|
|
229
|
+
labels.deploymentVersion = deploymentVersion
|
|
230
|
+
}
|
|
226
231
|
|
|
227
232
|
config.hotReload = false
|
|
228
233
|
config.restartOnError = 1000
|
package/package.json
CHANGED
package/test/init.test.js
CHANGED
|
@@ -437,6 +437,7 @@ test('updateInstanceConfig calls runtime.updateMetricsConfig with merged config'
|
|
|
437
437
|
applicationId,
|
|
438
438
|
applicationName,
|
|
439
439
|
applicationMetricsLabel,
|
|
440
|
+
deploymentVersion: 'v-metrics',
|
|
440
441
|
iccServices: {
|
|
441
442
|
riskEngine: { url: 'http://127.0.0.1:3000/risk-service' },
|
|
442
443
|
trafficInspector: { url: 'http://127.0.0.1:3000/traffic-inspector' },
|
|
@@ -502,6 +503,7 @@ test('updateInstanceConfig calls runtime.updateMetricsConfig with merged config'
|
|
|
502
503
|
equal(receivedMetricsConfig.labels.serviceId, 'main')
|
|
503
504
|
equal(receivedMetricsConfig.labels.instanceId, hostname())
|
|
504
505
|
equal(receivedMetricsConfig.labels.applicationId, applicationId)
|
|
506
|
+
equal(receivedMetricsConfig.labels.deploymentVersion, 'v-metrics')
|
|
505
507
|
equal(receivedMetricsConfig.applicationLabel, applicationMetricsLabel)
|
|
506
508
|
})
|
|
507
509
|
|
package/test/metrics.test.js
CHANGED
|
@@ -13,11 +13,18 @@ const __dirname = dirname(__filename)
|
|
|
13
13
|
test('should generate metrics with a correct labels', async (t) => {
|
|
14
14
|
const applicationName = 'test-app'
|
|
15
15
|
const applicationId = randomUUID()
|
|
16
|
+
const deploymentVersion = 'v-metrics'
|
|
16
17
|
const applicationPath = join(__dirname, 'fixtures', 'service-1')
|
|
17
18
|
|
|
18
19
|
const icc = await startICC(t, {
|
|
19
20
|
applicationId,
|
|
20
|
-
applicationName
|
|
21
|
+
applicationName,
|
|
22
|
+
controlPlaneResponse: {
|
|
23
|
+
applicationId,
|
|
24
|
+
applicationName,
|
|
25
|
+
deploymentVersion,
|
|
26
|
+
config: {}
|
|
27
|
+
}
|
|
21
28
|
})
|
|
22
29
|
|
|
23
30
|
process.env.PLT_TEST_APP_1_URL = 'http://test-app-1:3042'
|
|
@@ -54,6 +61,7 @@ test('should generate metrics with a correct labels', async (t) => {
|
|
|
54
61
|
const labels = eluMetrics.values[0].labels
|
|
55
62
|
assert.strictEqual(labels.applicationId, applicationId)
|
|
56
63
|
assert.strictEqual(labels.serviceId, 'main')
|
|
64
|
+
assert.strictEqual(labels.deploymentVersion, deploymentVersion)
|
|
57
65
|
}
|
|
58
66
|
})
|
|
59
67
|
|
|
@@ -14,11 +14,22 @@ const __dirname = dirname(__filename)
|
|
|
14
14
|
test('should spawn a service app settings labels for metrics', async (t) => {
|
|
15
15
|
const applicationName = 'test-application'
|
|
16
16
|
const applicationId = randomUUID()
|
|
17
|
+
const deploymentVersion = 'v-config'
|
|
17
18
|
const applicationPath = join(__dirname, 'fixtures', 'service-1')
|
|
18
19
|
|
|
19
20
|
const icc = await startICC(t, {
|
|
20
21
|
applicationId,
|
|
21
22
|
applicationName,
|
|
23
|
+
controlPlaneResponse: {
|
|
24
|
+
applicationId,
|
|
25
|
+
applicationName,
|
|
26
|
+
deploymentVersion,
|
|
27
|
+
enableOpenTelemetry: true,
|
|
28
|
+
iccServices: {
|
|
29
|
+
riskEngine: { url: 'http://127.0.0.1:3001/risk-service' }
|
|
30
|
+
},
|
|
31
|
+
config: {}
|
|
32
|
+
},
|
|
22
33
|
enableOpenTelemetry: true,
|
|
23
34
|
port: 3001
|
|
24
35
|
})
|
|
@@ -82,6 +93,7 @@ test('should spawn a service app settings labels for metrics', async (t) => {
|
|
|
82
93
|
serviceId: 'main',
|
|
83
94
|
instanceId: app.instanceId,
|
|
84
95
|
applicationId,
|
|
96
|
+
deploymentVersion,
|
|
85
97
|
},
|
|
86
98
|
applicationLabel: 'serviceId',
|
|
87
99
|
httpCustomLabels: [
|