@platformatic/watt-extra 1.7.0 → 1.7.1-alpha.2
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 +5 -8
- package/package.json +1 -1
- package/plugins/alerts.js +11 -6
- package/plugins/env.js +2 -3
- package/plugins/flamegraphs.js +330 -205
- package/plugins/health-signals.js +9 -8
- package/plugins/update.js +2 -2
- package/test/alerts.test.js +106 -26
- package/test/fixtures/service-1/routes/root.cjs +13 -1
- package/test/health-signals.test.js +166 -10
- package/test/profiler.test.js +443 -0
- package/test/trigger-flamegraphs.test.js +257 -416
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"permissions": {
|
|
3
3
|
"allow": [
|
|
4
|
-
"
|
|
5
|
-
"Bash(
|
|
6
|
-
"Bash(
|
|
7
|
-
"Bash(
|
|
8
|
-
"Bash(
|
|
9
|
-
"Bash(find:*)",
|
|
10
|
-
"Bash(cat:*)",
|
|
11
|
-
"WebFetch(domain:github.com)"
|
|
4
|
+
"Bash(node --test-only:*)",
|
|
5
|
+
"Bash(node --test:*)",
|
|
6
|
+
"Bash(for i in {1..3})",
|
|
7
|
+
"Bash(do echo \"=== Run $i ===\")",
|
|
8
|
+
"Bash(done)"
|
|
12
9
|
],
|
|
13
10
|
"deny": [],
|
|
14
11
|
"ask": []
|
package/package.json
CHANGED
package/plugins/alerts.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { request } from 'undici'
|
|
2
2
|
|
|
3
3
|
async function alerts (app, _opts) {
|
|
4
|
+
const pauseEluThreshold = app.env.PLT_FLAMEGRAPHS_PAUSE_ELU_TRESHOLD
|
|
5
|
+
const pauseTimeout = app.env.PLT_FLAMEGRAPHS_PAUSE_TIMEOUT
|
|
6
|
+
|
|
4
7
|
const healthCache = [] // It's OK to have this in memory, this is per-pod.
|
|
5
8
|
const podHealthWindow =
|
|
6
9
|
app.instanceConfig?.scaler?.podHealthWindow || 60 * 1000
|
|
@@ -61,6 +64,12 @@ async function alerts (app, _opts) {
|
|
|
61
64
|
const healthWithTimestamp = { ...healthInfo, timestamp, service: serviceId }
|
|
62
65
|
delete healthWithTimestamp.healthConfig // we don't need to store this
|
|
63
66
|
|
|
67
|
+
const elu = healthInfo.currentHealth.elu
|
|
68
|
+
process._rawDebug('--------ALERT-------', elu)
|
|
69
|
+
if (elu >= pauseEluThreshold) {
|
|
70
|
+
app.pauseProfiling({ serviceId, timeout: pauseTimeout })
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
healthCache.push(healthWithTimestamp)
|
|
65
74
|
|
|
66
75
|
const cutoffTime = timestamp - podHealthWindow
|
|
@@ -136,12 +145,8 @@ async function alerts (app, _opts) {
|
|
|
136
145
|
|
|
137
146
|
const alert = await body.json()
|
|
138
147
|
|
|
139
|
-
app.
|
|
140
|
-
|
|
141
|
-
alertId: alert.id
|
|
142
|
-
}).catch(err => {
|
|
143
|
-
app.log.error({ err }, 'Failed to send a flamegraph')
|
|
144
|
-
})
|
|
148
|
+
app.requestFlamegraphs({ serviceIds: [serviceId], alertId: alert.id })
|
|
149
|
+
.catch(err => app.log.error({ err }, 'Failed to send a flamegraph'))
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
|
package/plugins/env.js
CHANGED
|
@@ -19,10 +19,9 @@ const schema = {
|
|
|
19
19
|
PLT_CACHE_CONFIG: { type: 'string' },
|
|
20
20
|
PLT_DISABLE_FLAMEGRAPHS: { type: 'boolean', default: false },
|
|
21
21
|
PLT_FLAMEGRAPHS_INTERVAL_SEC: { type: 'number', default: 60 },
|
|
22
|
-
PLT_FLAMEGRAPHS_ELU_THRESHOLD: { type: 'number', default: 0.4 },
|
|
23
22
|
PLT_FLAMEGRAPHS_GRACE_PERIOD: { type: 'number', default: 3000 },
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
PLT_FLAMEGRAPHS_PAUSE_ELU_TRESHOLD: { type: 'number', default: 0.95 },
|
|
24
|
+
PLT_FLAMEGRAPHS_PAUSE_TIMEOUT: { type: 'number', default: 5 * 60 * 1000 },
|
|
26
25
|
PLT_JWT_EXPIRATION_OFFSET_SEC: { type: 'number', default: 60 },
|
|
27
26
|
PLT_UPDATES_RECONNECT_INTERVAL_SEC: { type: 'number', default: 1 },
|
|
28
27
|
PLT_ELU_HEALTH_SIGNAL_THRESHOLD: { type: 'number', default: 0.8 },
|