@platformatic/watt-extra 1.5.3-alpha.0 → 1.5.3
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/package.json +2 -2
- package/plugins/alerts.js +3 -1
- package/test/alerts.test.js +16 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/watt-extra",
|
|
3
|
-
"version": "1.5.3
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "The Platformatic runtime manager",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"fastify": "^5.4.0",
|
|
30
30
|
"fastify-plugin": "^5.0.1",
|
|
31
31
|
"neostandard": "^0.12.0",
|
|
32
|
-
"next": "^
|
|
32
|
+
"next": "^16.0.0",
|
|
33
33
|
"platformatic": "^3.14.0",
|
|
34
34
|
"pprof-format": "^2.1.0",
|
|
35
35
|
"why-is-node-running": "^2.3.0"
|
package/plugins/alerts.js
CHANGED
|
@@ -40,7 +40,8 @@ async function alerts (app, _opts) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const timestamp = Date.now()
|
|
43
|
-
const
|
|
43
|
+
const serviceId = healthInfo.application
|
|
44
|
+
const healthWithTimestamp = { ...healthInfo, timestamp, service: serviceId }
|
|
44
45
|
delete healthWithTimestamp.healthConfig // we don't need to store this
|
|
45
46
|
|
|
46
47
|
healthCache.push(healthWithTimestamp)
|
|
@@ -76,6 +77,7 @@ async function alerts (app, _opts) {
|
|
|
76
77
|
const currentTime = Date.now()
|
|
77
78
|
|
|
78
79
|
const serviceId = healthInfo.application
|
|
80
|
+
healthInfo.service = serviceId // ICC expects "service" field
|
|
79
81
|
const lastAlertTime = lastServicesAlertTime[serviceId]
|
|
80
82
|
|
|
81
83
|
if (lastAlertTime && currentTime - lastAlertTime < alertRetentionWindow) {
|
package/test/alerts.test.js
CHANGED
|
@@ -88,9 +88,12 @@ test('should send alert when service becomes unhealthy', async (t) => {
|
|
|
88
88
|
assert.ok(alertReceived, 'Alert should have been received')
|
|
89
89
|
assert.strictEqual(alertReceived.applicationId, applicationId)
|
|
90
90
|
assert.deepStrictEqual(alertReceived.alert, healthInfo)
|
|
91
|
+
assert.strictEqual(alertReceived.alert.application, 'main')
|
|
92
|
+
assert.strictEqual(alertReceived.alert.service, 'main')
|
|
91
93
|
assert.ok(Array.isArray(alertReceived.healthHistory), 'Health history should be an array')
|
|
92
94
|
assert.ok(alertReceived.healthHistory.length > 0, 'Health history should not be empty')
|
|
93
95
|
assert.strictEqual(alertReceived.healthHistory[0].application, 'main')
|
|
96
|
+
assert.strictEqual(alertReceived.healthHistory[0].service, 'main')
|
|
94
97
|
|
|
95
98
|
assert.ok(flamegraphReceived, 'Flamegraph should have been received')
|
|
96
99
|
|
|
@@ -254,7 +257,8 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
254
257
|
assert.strictEqual(alertReceived.applicationId, applicationId)
|
|
255
258
|
|
|
256
259
|
assert.strictEqual(alertReceived.alert.id, unhealthyInfo.id)
|
|
257
|
-
assert.strictEqual(alertReceived.alert.
|
|
260
|
+
assert.strictEqual(alertReceived.alert.application, 'service-1')
|
|
261
|
+
assert.strictEqual(alertReceived.alert.service, 'service-1')
|
|
258
262
|
assert.strictEqual(alertReceived.alert.unhealthy, unhealthyInfo.unhealthy)
|
|
259
263
|
|
|
260
264
|
assert.ok(Array.isArray(alertReceived.healthHistory), 'Health history should be an array')
|
|
@@ -264,7 +268,9 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
264
268
|
assert.ok('unhealthy' in entry, 'Entry should have unhealthy property')
|
|
265
269
|
assert.ok('currentHealth' in entry, 'Entry should have currentHealth property')
|
|
266
270
|
assert.ok('timestamp' in entry, 'Entry should have timestamp property')
|
|
267
|
-
assert.ok('service' in entry
|
|
271
|
+
assert.ok('service' in entry, 'Entry should have service property')
|
|
272
|
+
assert.ok('application' in entry, 'Entry should have application property')
|
|
273
|
+
assert.strictEqual(entry.service, entry.application, 'service should match application')
|
|
268
274
|
assert.ok(!('healthConfig' in entry), 'Entry should not have healthConfig property')
|
|
269
275
|
}
|
|
270
276
|
|
|
@@ -489,7 +495,7 @@ test('should send alert when flamegraphs are disabled', async (t) => {
|
|
|
489
495
|
// Manually trigger health event with unhealthy state
|
|
490
496
|
const healthInfo = {
|
|
491
497
|
id: 'main:0',
|
|
492
|
-
|
|
498
|
+
application: 'main',
|
|
493
499
|
currentHealth: {
|
|
494
500
|
elu: 0.95,
|
|
495
501
|
heapUsed: 76798040,
|
|
@@ -514,8 +520,11 @@ test('should send alert when flamegraphs are disabled', async (t) => {
|
|
|
514
520
|
assert.ok(alertReceived, 'Alert should have been received')
|
|
515
521
|
assert.strictEqual(alertReceived.applicationId, applicationId)
|
|
516
522
|
assert.deepStrictEqual(alertReceived.alert, healthInfo)
|
|
523
|
+
assert.strictEqual(alertReceived.alert.application, 'main')
|
|
524
|
+
assert.strictEqual(alertReceived.alert.service, 'main')
|
|
517
525
|
assert.ok(Array.isArray(alertReceived.healthHistory), 'Health history should be an array')
|
|
518
526
|
assert.ok(alertReceived.healthHistory.length > 0, 'Health history should not be empty')
|
|
527
|
+
assert.strictEqual(alertReceived.healthHistory[0].application, 'main')
|
|
519
528
|
assert.strictEqual(alertReceived.healthHistory[0].service, 'main')
|
|
520
529
|
assert.equal(alertReceived.flamegraph, null, 'Flamegraph should be null')
|
|
521
530
|
})
|
|
@@ -566,7 +575,7 @@ test('should send alert when failed to send a flamegraph', async (t) => {
|
|
|
566
575
|
// Manually trigger health event with unhealthy state
|
|
567
576
|
const healthInfo = {
|
|
568
577
|
id: 'main:0',
|
|
569
|
-
|
|
578
|
+
application: 'main',
|
|
570
579
|
currentHealth: {
|
|
571
580
|
elu: 0.95,
|
|
572
581
|
heapUsed: 76798040,
|
|
@@ -591,8 +600,11 @@ test('should send alert when failed to send a flamegraph', async (t) => {
|
|
|
591
600
|
assert.ok(alertReceived, 'Alert should have been received')
|
|
592
601
|
assert.strictEqual(alertReceived.applicationId, applicationId)
|
|
593
602
|
assert.deepStrictEqual(alertReceived.alert, healthInfo)
|
|
603
|
+
assert.strictEqual(alertReceived.alert.application, 'main')
|
|
604
|
+
assert.strictEqual(alertReceived.alert.service, 'main')
|
|
594
605
|
assert.ok(Array.isArray(alertReceived.healthHistory), 'Health history should be an array')
|
|
595
606
|
assert.ok(alertReceived.healthHistory.length > 0, 'Health history should not be empty')
|
|
607
|
+
assert.strictEqual(alertReceived.healthHistory[0].application, 'main')
|
|
596
608
|
assert.strictEqual(alertReceived.healthHistory[0].service, 'main')
|
|
597
609
|
assert.equal(alertReceived.flamegraph, null, 'Flamegraph should be null')
|
|
598
610
|
})
|