@platformatic/watt-extra 0.1.7-alpha.2 → 0.1.7
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 +0 -1
- package/package.json +8 -8
- package/plugins/alerts.js +0 -5
- package/test/alerts.test.js +10 -10
package/lib/watt.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/watt-extra",
|
|
3
|
-
"version": "0.1.7
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "The Platformatic runtime manager",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,25 +13,25 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@fastify/websocket": "^11.1.0",
|
|
16
|
-
"@platformatic/composer": "^3.0.
|
|
17
|
-
"@platformatic/next": "^3.0.
|
|
18
|
-
"@platformatic/node": "^3.0.
|
|
19
|
-
"@platformatic/service": "^3.0.
|
|
16
|
+
"@platformatic/composer": "^3.0.5",
|
|
17
|
+
"@platformatic/next": "^3.0.5",
|
|
18
|
+
"@platformatic/node": "^3.0.5",
|
|
19
|
+
"@platformatic/service": "^3.0.5",
|
|
20
20
|
"borp": "^0.20.0",
|
|
21
21
|
"eslint": "9",
|
|
22
22
|
"fastify": "^5.4.0",
|
|
23
23
|
"fastify-plugin": "^5.0.1",
|
|
24
24
|
"neostandard": "^0.12.0",
|
|
25
25
|
"next": "^15.3.4",
|
|
26
|
-
"platformatic": "^3.0.
|
|
26
|
+
"platformatic": "^3.0.5",
|
|
27
27
|
"pprof-format": "^2.1.0",
|
|
28
28
|
"why-is-node-running": "^2.3.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@datadog/pprof": "^5.9.0",
|
|
32
32
|
"@fastify/error": "^4.2.0",
|
|
33
|
-
"@platformatic/runtime": "^3.0.
|
|
34
|
-
"@platformatic/wattpm-pprof-capture": "^3.0.
|
|
33
|
+
"@platformatic/runtime": "^3.0.5",
|
|
34
|
+
"@platformatic/wattpm-pprof-capture": "^3.0.5",
|
|
35
35
|
"avvio": "^9.1.0",
|
|
36
36
|
"chalk": "^4.1.2",
|
|
37
37
|
"commist": "^3.2.0",
|
package/plugins/alerts.js
CHANGED
|
@@ -26,8 +26,6 @@ async function alerts (app, _opts) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
runtime.on('application:worker:health', async (healthInfo) => {
|
|
29
|
-
process._rawDebug('-------RUNTIME ON HEALTH---------', JSON.stringify(healthInfo, null, 2))
|
|
30
|
-
|
|
31
29
|
if (!healthInfo) {
|
|
32
30
|
app.log.error('No health info received')
|
|
33
31
|
return
|
|
@@ -78,7 +76,6 @@ async function alerts (app, _opts) {
|
|
|
78
76
|
|
|
79
77
|
const authHeaders = await app.getAuthorizationHeader()
|
|
80
78
|
|
|
81
|
-
process._rawDebug('-------SENDING ALERT---------', JSON.stringify(healthInfo, null, 2), `${scalerUrl}/alerts`)
|
|
82
79
|
const { statusCode, body } = await request(`${scalerUrl}/alerts`, {
|
|
83
80
|
method: 'POST',
|
|
84
81
|
headers: {
|
|
@@ -92,8 +89,6 @@ async function alerts (app, _opts) {
|
|
|
92
89
|
}),
|
|
93
90
|
})
|
|
94
91
|
|
|
95
|
-
process._rawDebug('--------ALERT SENT---------', statusCode)
|
|
96
|
-
|
|
97
92
|
if (statusCode !== 200) {
|
|
98
93
|
const error = await body.text()
|
|
99
94
|
app.log.error({ error }, 'Failed to send alert to scaler')
|
package/test/alerts.test.js
CHANGED
|
@@ -82,7 +82,7 @@ test('should send alert when service becomes unhealthy', async (t) => {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
app.watt.runtime.emit('health', healthInfo)
|
|
85
|
+
app.watt.runtime.emit('application:worker:health', healthInfo)
|
|
86
86
|
|
|
87
87
|
await sleep(200)
|
|
88
88
|
|
|
@@ -158,7 +158,7 @@ test('should not send alert when service is healthy', async (t) => {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
app.watt.runtime.emit('health', healthInfo)
|
|
161
|
+
app.watt.runtime.emit('application:worker:health', healthInfo)
|
|
162
162
|
|
|
163
163
|
await sleep(200)
|
|
164
164
|
|
|
@@ -227,7 +227,7 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
app.watt.runtime.emit('health', healthyInfo)
|
|
230
|
+
app.watt.runtime.emit('application:worker:health', healthyInfo)
|
|
231
231
|
await sleep(100) // Small delay between events
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -252,7 +252,7 @@ test('should cache health data and include it in alerts', async (t) => {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
app.watt.runtime.emit('health', unhealthyInfo)
|
|
255
|
+
app.watt.runtime.emit('application:worker:health', unhealthyInfo)
|
|
256
256
|
await sleep(200)
|
|
257
257
|
|
|
258
258
|
assert.ok(alertReceived, 'Alert should have been received')
|
|
@@ -320,7 +320,7 @@ test('should not fail when health info is missing', async (t) => {
|
|
|
320
320
|
await icc.close()
|
|
321
321
|
})
|
|
322
322
|
|
|
323
|
-
app.watt.runtime.emit('health', null)
|
|
323
|
+
app.watt.runtime.emit('application:worker:health', null)
|
|
324
324
|
|
|
325
325
|
await sleep(200)
|
|
326
326
|
|
|
@@ -393,11 +393,11 @@ test('should respect alert retention window', async (t) => {
|
|
|
393
393
|
})
|
|
394
394
|
|
|
395
395
|
// Send first unhealthy event - should trigger alert
|
|
396
|
-
app.watt.runtime.emit('health', createHealthInfo(true))
|
|
396
|
+
app.watt.runtime.emit('application:worker:health', createHealthInfo(true))
|
|
397
397
|
await sleep(100)
|
|
398
398
|
|
|
399
399
|
// Send second unhealthy event immediately - should be ignored due to retention window
|
|
400
|
-
app.watt.runtime.emit('health', createHealthInfo(true))
|
|
400
|
+
app.watt.runtime.emit('application:worker:health', createHealthInfo(true))
|
|
401
401
|
await sleep(100)
|
|
402
402
|
|
|
403
403
|
assert.strictEqual(alertsReceived.length, 1, 'Only one alert should be sent within retention window')
|
|
@@ -405,7 +405,7 @@ test('should respect alert retention window', async (t) => {
|
|
|
405
405
|
await sleep(500)
|
|
406
406
|
|
|
407
407
|
// Send third unhealthy event - should trigger second alert
|
|
408
|
-
app.watt.runtime.emit('health', createHealthInfo(true))
|
|
408
|
+
app.watt.runtime.emit('application:worker:health', createHealthInfo(true))
|
|
409
409
|
await sleep(100)
|
|
410
410
|
|
|
411
411
|
assert.strictEqual(alertsReceived.length, 2, 'Second alert should be sent after retention window expires')
|
|
@@ -514,7 +514,7 @@ test('should send alert when flamegraphs are disabled', async (t) => {
|
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
-
app.watt.runtime.emit('health', healthInfo)
|
|
517
|
+
app.watt.runtime.emit('application:worker:health', healthInfo)
|
|
518
518
|
|
|
519
519
|
await sleep(200)
|
|
520
520
|
|
|
@@ -593,7 +593,7 @@ test('should send alert when failed to send a flamegraph', async (t) => {
|
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
|
|
596
|
-
app.watt.runtime.emit('health', healthInfo)
|
|
596
|
+
app.watt.runtime.emit('application:worker:health', healthInfo)
|
|
597
597
|
|
|
598
598
|
await sleep(200)
|
|
599
599
|
|