@platformatic/watt-extra 1.5.2 → 1.5.3-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/.claude/settings.local.json +11 -0
- package/package.json +2 -2
- package/plugins/alerts.js +4 -2
- package/test/alerts.test.js +24 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/watt-extra",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3-alpha.1",
|
|
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)
|
|
@@ -75,7 +76,8 @@ async function alerts (app, _opts) {
|
|
|
75
76
|
if (healthInfo.unhealthy) {
|
|
76
77
|
const currentTime = Date.now()
|
|
77
78
|
|
|
78
|
-
const serviceId = healthInfo.
|
|
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
|
@@ -63,7 +63,7 @@ test('should send alert when service becomes unhealthy', async (t) => {
|
|
|
63
63
|
// Manually trigger health event with unhealthy state
|
|
64
64
|
const healthInfo = {
|
|
65
65
|
id: 'main:0',
|
|
66
|
-
|
|
66
|
+
application: 'main',
|
|
67
67
|
currentHealth: {
|
|
68
68
|
elu: 0.95,
|
|
69
69
|
heapUsed: 76798040,
|
|
@@ -88,8 +88,11 @@ 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')
|
|
95
|
+
assert.strictEqual(alertReceived.healthHistory[0].application, 'main')
|
|
93
96
|
assert.strictEqual(alertReceived.healthHistory[0].service, 'main')
|
|
94
97
|
|
|
95
98
|
assert.ok(flamegraphReceived, 'Flamegraph should have been received')
|
|
@@ -98,7 +101,7 @@ test('should send alert when service becomes unhealthy', async (t) => {
|
|
|
98
101
|
assert.ok(profile, 'Profile should be decoded')
|
|
99
102
|
})
|
|
100
103
|
|
|
101
|
-
test('should not send alert when
|
|
104
|
+
test('should not send alert when application is healthy', async (t) => {
|
|
102
105
|
const applicationName = 'test-app'
|
|
103
106
|
const applicationId = randomUUID()
|
|
104
107
|
const applicationPath = join(__dirname, 'fixtures', 'service-1')
|
|
@@ -137,7 +140,7 @@ test('should not send alert when service is healthy', async (t) => {
|
|
|
137
140
|
// Manually trigger health event with healthy state
|
|
138
141
|
const healthInfo = {
|
|
139
142
|
id: 'service-1',
|
|
140
|
-
|
|
143
|
+
application: 'service-1',
|
|
141
144
|
currentHealth: {
|
|
142
145
|
elu: 0.5,
|
|
143
146
|
heapUsed: 76798040,
|
|
@@ -204,7 +207,7 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
204
207
|
for (let i = 0; i < 3; i++) {
|
|
205
208
|
const healthyInfo = {
|
|
206
209
|
id: 'service-1',
|
|
207
|
-
|
|
210
|
+
application: 'service-1',
|
|
208
211
|
currentHealth: {
|
|
209
212
|
elu: 0.5 + (i * 0.1), // Different values to distinguish them
|
|
210
213
|
heapUsed: 76798040,
|
|
@@ -229,7 +232,7 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
229
232
|
// Now send an unhealthy event to trigger alert
|
|
230
233
|
const unhealthyInfo = {
|
|
231
234
|
id: 'service-1',
|
|
232
|
-
|
|
235
|
+
application: 'service-1',
|
|
233
236
|
currentHealth: {
|
|
234
237
|
elu: 0.95,
|
|
235
238
|
heapUsed: 76798040,
|
|
@@ -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
|
|
|
@@ -363,9 +369,9 @@ test('should respect alert retention window', async (t) => {
|
|
|
363
369
|
})
|
|
364
370
|
|
|
365
371
|
// Create a health info template
|
|
366
|
-
const createHealthInfo = (
|
|
367
|
-
id:
|
|
368
|
-
|
|
372
|
+
const createHealthInfo = (applicationId, unhealthy = true) => ({
|
|
373
|
+
id: applicationId,
|
|
374
|
+
application: applicationId,
|
|
369
375
|
currentHealth: {
|
|
370
376
|
elu: unhealthy ? 0.95 : 0.5,
|
|
371
377
|
heapUsed: 76798040,
|
|
@@ -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
|
})
|