@platformatic/watt-extra 1.11.1 → 1.11.2-alpha.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.11.1",
3
+ "version": "1.11.2-alpha.0",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
package/plugins/env.js CHANGED
@@ -25,11 +25,13 @@ const schema = {
25
25
  PLT_FLAMEGRAPHS_CACHE_CLEANUP_INTERVAL: { type: 'number', default: 120000 },
26
26
  PLT_JWT_EXPIRATION_OFFSET_SEC: { type: 'number', default: 60 },
27
27
  PLT_UPDATES_RECONNECT_INTERVAL_SEC: { type: 'number', default: 1 },
28
- PLT_ELU_HEALTH_SIGNAL_THRESHOLD: { type: 'number', default: 0.8 },
29
- PLT_HEAP_HEALTH_SIGNAL_THRESHOLD: { type: ['number', 'string'], default: '200MB' },
28
+ PLT_ELU_HEALTH_SIGNAL_THRESHOLD: { type: 'number', default: 0.7 },
29
+ PLT_HEAP_HEALTH_SIGNAL_THRESHOLD: { type: ['number', 'string'], default: '400MB' },
30
30
  PLT_ALERTS_GRACE_PERIOD_SEC: { type: 'number', default: 30 },
31
31
  PLT_HEALTH_SIGNALS_SHORT_BATCH_TIMEOUT: { type: 'number', default: 5000 },
32
- PLT_HEALTH_SIGNALS_LONG_BATCH_TIMEOUT: { type: 'number', default: 30000 }
32
+ PLT_HEALTH_SIGNALS_LONG_BATCH_TIMEOUT: { type: 'number', default: 30000 },
33
+ PLT_HEALTH_SIGNALS_ELU_BATCH_THRESHOLD: { type: 'number', default: 0.5 },
34
+ PLT_HEALTH_SIGNALS_HEAP_BATCH_THRESHOLD: { type: ['number', 'string'], default: '300MB' },
33
35
  }
34
36
  }
35
37
 
@@ -86,15 +86,31 @@ async function healthSignals (app, _opts) {
86
86
  const runtime = app.watt.runtime
87
87
  const batchShortTimeout = app.env.PLT_HEALTH_SIGNALS_SHORT_BATCH_TIMEOUT
88
88
  const batchLongTimeout = app.env.PLT_HEALTH_SIGNALS_LONG_BATCH_TIMEOUT
89
+
89
90
  eluThreshold = app.env.PLT_ELU_HEALTH_SIGNAL_THRESHOLD
90
91
 
91
- // TODO: get the used heap and use the 0.8 by default as a threshold
92
+ let eluBatchThreshold = app.env.PLT_HEALTH_SIGNALS_ELU_BATCH_THRESHOLD
93
+ if (eluBatchThreshold > eluThreshold) {
94
+ eluBatchThreshold = eluThreshold
95
+ }
96
+
92
97
  let heapThreshold = app.env.PLT_HEAP_HEALTH_SIGNAL_THRESHOLD
93
98
  if (typeof heapThreshold === 'string') {
94
99
  heapThreshold = parseMemorySize(heapThreshold)
95
100
  }
101
+
102
+ let heapBatchThreshold = app.env.PLT_HEALTH_SIGNALS_HEAP_BATCH_THRESHOLD
103
+ if (typeof heapBatchThreshold === 'string') {
104
+ heapBatchThreshold = parseMemorySize(heapBatchThreshold)
105
+ }
106
+
96
107
  heapThresholdMb = Math.round(heapThreshold / 1024 / 1024)
97
108
 
109
+ let heapBatchThresholdMb = Math.round(heapBatchThreshold / 1024 / 1024)
110
+ if (heapBatchThresholdMb > heapThresholdMb) {
111
+ heapBatchThresholdMb = heapThresholdMb
112
+ }
113
+
98
114
  let batchHasHighValue = false
99
115
  let batchStartedAt = null
100
116
 
@@ -157,7 +173,7 @@ async function healthSignals (app, _opts) {
157
173
  heapTotalByService[serviceId] = heapTotal
158
174
  signalsCache.addServiceSignals(serviceId, healthSignals)
159
175
 
160
- if (elu > eluThreshold || heapUsedMb > heapThresholdMb) {
176
+ if (elu > eluBatchThreshold || heapUsedMb > heapBatchThresholdMb) {
161
177
  batchHasHighValue = true
162
178
  }
163
179
  }