@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.
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "permissions": {
3
3
  "allow": [
4
- "Read(//work/workspaces/workspace-platformatic/platformatic/**)",
5
- "Bash(npx borp:*)",
6
- "Bash(timeout 30 npx borp -c 1 --timeout=20000 ./test/trigger-flamegraphs.test.js)",
7
- "Bash(xargs cat:*)",
8
- "Bash(pnpm install)",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.7.0",
3
+ "version": "1.7.1-alpha.2",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
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.sendFlamegraphs({
140
- workerIds: [workerId],
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
- PLT_FLAMEGRAPHS_ATTEMPT_TIMEOUT: { type: 'number', default: 10000 },
25
- PLT_FLAMEGRAPHS_CACHE_CLEANUP_INTERVAL: { type: 'number', default: 120000 },
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 },