@luanpdd/kit-mcp 1.35.0 → 1.36.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/bin/cli.js +2 -2
- package/bin/mcp.js +6 -6
- package/bin/ui.js +74 -74
- package/gates/ai-prompt-stability.md +120 -120
- package/gates/budget-description.md +68 -68
- package/gates/confidence.md +29 -29
- package/gates/dependency-check.md +33 -33
- package/gates/dept-cycle-prevention.md +179 -179
- package/gates/golden-signals-coverage.md +133 -133
- package/gates/legacy-refactor-safety.md +178 -178
- package/gates/multi-tenant-rls-coverage.md +102 -102
- package/gates/no-personal-uuid.md +72 -72
- package/gates/obs-agents-mcp-supabase.md +86 -86
- package/gates/obs-skills-frontmatter.md +76 -76
- package/gates/observability-coverage.md +151 -151
- package/gates/omm-no-regression.md +83 -83
- package/gates/postmortem-template-required.md +127 -127
- package/gates/prr-checklist-coverage.md +128 -128
- package/gates/regression.md +32 -32
- package/gates/release-pipeline-policy.md +132 -132
- package/gates/secrets-scan.md +33 -33
- package/gates/service-role-not-in-user-facing.md +113 -113
- package/gates/skill-must-include.md +71 -71
- package/gates/sync-idempotent.md +62 -62
- package/gates/verify-phase-goal.md +34 -34
- package/kit/agents/designer-ui.md +216 -216
- package/kit/agents/workflow-generator.md +537 -167
- package/kit/commands/adicionar-backlog.md +1 -1
- package/kit/commands/adicionar-fase.md +1 -1
- package/kit/commands/adicionar-tarefa.md +1 -1
- package/kit/commands/auditar-observabilidade.md +103 -103
- package/kit/commands/auditar-toil.md +129 -129
- package/kit/commands/caracterizar-prompt.md +195 -195
- package/kit/commands/criar-workflow.md +158 -158
- package/kit/commands/definir-perfil.md +1 -1
- package/kit/commands/definir-slo.md +108 -108
- package/kit/commands/fio.md +1 -1
- package/kit/commands/golden-signals.md +142 -142
- package/kit/commands/instrumentar-fase.md +200 -200
- package/kit/commands/investigar-producao.md +162 -162
- package/kit/commands/observabilidade.md +118 -118
- package/kit/commands/postmortem.md +179 -179
- package/kit/commands/prr.md +205 -205
- package/kit/commands/publicar-rapido.md +207 -207
- package/kit/commands/risk-budget.md +220 -220
- package/kit/commands/sre.md +230 -230
- package/kit/file-manifest.json +424 -424
- package/kit/framework/references/output-style.md +22 -22
- package/kit/hooks/post-apply-migration.js +199 -199
- package/kit/hooks/sidecar-tool-publisher.js +210 -210
- package/kit/skills/_shared-dados-distribuidos/glossary.md +224 -224
- package/kit/skills/_shared-legacy/glossary.md +389 -389
- package/kit/skills/_shared-multi-tenant/glossary.md +186 -186
- package/kit/skills/_shared-observability/glossary.md +396 -396
- package/kit/skills/_shared-sre/glossary.md +712 -712
- package/kit/skills/_shared-supabase/glossary.md +234 -234
- package/kit/skills/blameless-postmortems/SKILL.md +340 -340
- package/kit/skills/burn-rate-alerting/SKILL.md +258 -258
- package/kit/skills/cascading-failures/SKILL.md +311 -311
- package/kit/skills/core-analysis-loop/SKILL.md +352 -352
- package/kit/skills/distributed-tracing/SKILL.md +362 -362
- package/kit/skills/dynamic-workflow-authoring/SKILL.md +327 -223
- package/kit/skills/eliminating-toil/SKILL.md +243 -243
- package/kit/skills/event-based-slos/SKILL.md +296 -296
- package/kit/skills/four-golden-signals/SKILL.md +314 -314
- package/kit/skills/hermetic-builds/SKILL.md +323 -323
- package/kit/skills/legacy-monster-methods/SKILL.md +444 -444
- package/kit/skills/llm-as-dependency/SKILL.md +436 -436
- package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -396
- package/kit/skills/observability-driven-development/SKILL.md +315 -315
- package/kit/skills/observability-maturity-model/SKILL.md +222 -222
- package/kit/skills/opentelemetry-standard/SKILL.md +351 -351
- package/kit/skills/production-readiness-review/SKILL.md +305 -305
- package/kit/skills/release-engineering/SKILL.md +367 -367
- package/kit/skills/retry-strategies/SKILL.md +372 -372
- package/kit/skills/sre-risk-management/SKILL.md +221 -221
- package/kit/skills/structured-events/SKILL.md +265 -265
- package/kit/skills/supabase-cron-queues/SKILL.md +275 -275
- package/kit/skills/supabase-database-functions/SKILL.md +332 -332
- package/kit/skills/supabase-declarative-schema/SKILL.md +183 -183
- package/kit/skills/supabase-pgvector-rag/SKILL.md +253 -253
- package/kit/skills/supabase-postgres-style/SKILL.md +138 -138
- package/kit/skills/supabase-storage/SKILL.md +234 -234
- package/kit/skills/telemetry-pipelines/SKILL.md +259 -259
- package/kit/skills/telemetry-sampling/SKILL.md +256 -256
- package/kit/skills/ui-anti-padroes-ia/SKILL.md +261 -261
- package/kit/skills/ui-contexto-produto/SKILL.md +248 -248
- package/kit/skills/ui-cor-estrategia/SKILL.md +213 -213
- package/kit/skills/ui-critica-auditoria/SKILL.md +260 -260
- package/kit/skills/ui-motion-funcional/SKILL.md +264 -264
- package/kit/skills/ui-ritmo-espacial/SKILL.md +259 -259
- package/kit/skills/ui-tipografia/SKILL.md +211 -211
- package/package.json +1 -1
- package/src/cli/index.js +1114 -1114
- package/src/cli/render.js +194 -194
- package/src/cli/upgrade-check.js +135 -135
- package/src/core/error-redaction.js +76 -76
- package/src/core/failures.js +153 -153
- package/src/core/gate-runner.js +205 -205
- package/src/core/gates.js +82 -82
- package/src/core/logger.js +170 -170
- package/src/core/manifest-verify.js +174 -174
- package/src/core/metrics.js +268 -268
- package/src/core/notify.js +60 -60
- package/src/core/path-safety.js +141 -141
- package/src/core/replays.js +120 -120
- package/src/core/ui.js +185 -185
- package/src/mcp-server/install.js +149 -149
- package/src/mcp-server/roots.js +124 -124
- package/src/ui/auto-spawn.js +113 -113
- package/src/ui/browser.js +78 -78
- package/src/ui/client.js +130 -130
- package/src/ui/events.js +65 -65
- package/src/ui/lockfile.js +191 -191
- package/src/ui/port.js +67 -67
- package/src/ui/server.js +547 -547
- package/src/ui/wrapper.js +129 -129
|
@@ -1,314 +1,314 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: four-golden-signals
|
|
3
|
-
description: Use ao instrumentar serviço user-facing — Latency + Traffic + Errors + Saturation, percentis (não mean), histogram exponencial, latência success vs error separadas.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# SRE — Four Golden Signals
|
|
7
|
-
|
|
8
|
-
## Quando usar
|
|
9
|
-
|
|
10
|
-
LLM carrega esta skill ao instrumentar Edge Function/serviço/microservice user-facing. Trigger phrases:
|
|
11
|
-
|
|
12
|
-
- "golden signals", "4 sinais dourados"
|
|
13
|
-
- "latency, traffic, errors, saturation"
|
|
14
|
-
- "instrumentar serviço", "métricas mínimas"
|
|
15
|
-
- "p99 latency", "percentis vs mean"
|
|
16
|
-
- "black-box vs white-box monitoring"
|
|
17
|
-
- "Google SRE cap 6"
|
|
18
|
-
- "Latency success vs error"
|
|
19
|
-
|
|
20
|
-
## Regras absolutas
|
|
21
|
-
|
|
22
|
-
- **4 sinais são universais para serviço user-facing** — Latency + Traffic + Errors + Saturation. Se mede esses 4, captura ~95% da saúde operacional. Outros sinais (CPU, memória, disco I/O) são **causas potenciais**, não sintomas — vão em white-box monitoring secundário.
|
|
23
|
-
- **Latency success vs error sempre separadas** — falhas rápidas (HTTP 500 em 5ms) mascaram latência ruim de successes se misturadas. Sempre `histogram(duration_ms, {result: 'success'})` e `histogram(duration_ms, {result: 'error'})` em séries distintas.
|
|
24
|
-
- **NUNCA mean para latency** — long tail invisível: mean=50ms mas p99=5000ms é UX ruim para 1% dos usuários (tipicamente os mais valiosos: enterprise tier). SEMPRE histogram com percentis.
|
|
25
|
-
- **Histogram com bucketing exponencial** — buckets `[1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000]` ms ou base 1.5/2. Captura long tail sem cardinality explosion.
|
|
26
|
-
- **Errors counter por error.type (não message)** — `error.type` enumerado (5-15 valores: `timeout`, `validation`, `auth`, `rate_limit`, `db`, `provider_down`, ...). `error.message` é alta cardinalidade — não usar como dimension.
|
|
27
|
-
- **Saturation é resource-specific** — não existe métrica genérica de saturação. Para HTTP service: connection pool used %. Para DB: tablespace used %. Para queue: queue depth. Para CPU-bound: load average. Identificar O recurso mais escasso ANTES de instrumentar.
|
|
28
|
-
- **Black-box monitora UX, white-box monitora internals** — black-box (synthetic prober HTTP) detecta "site offline" mesmo se métricas internas estão verdes (corner case clássico). White-box (golden signals) explica "porquê" quando black-box dispara.
|
|
29
|
-
- **Reportar p50, p95, p99, p99.9 — não só p99** — p50 (mediana) é UX típica; p95 é primeiro deslize; p99 é cauda; p99.9 é seu 1 em 1000 que é seu cliente enterprise. Cada percentil conta uma história diferente.
|
|
30
|
-
|
|
31
|
-
## Patterns canônicos
|
|
32
|
-
|
|
33
|
-
### Pattern: definição canônica dos 4 signals (tabela)
|
|
34
|
-
|
|
35
|
-
| Signal | Definição | Tipo de instrument | Granularity recomendada |
|
|
36
|
-
|---|---|---|---|
|
|
37
|
-
| **Latency** | Tempo de request bem-sucedido vs falho — SEPARADO | Histogram (ms) com bucketing exponencial | Por endpoint × `result` (success/error) |
|
|
38
|
-
| **Traffic** | Volume de demanda — requests/s, msgs/s, bytes/s | Counter | Por endpoint × method |
|
|
39
|
-
| **Errors** | Taxa de requests que falharam (explícitas: 5xx; implícitas: 200 com payload errado; políticas: > SLO target) | Counter | Por endpoint × `error.type` |
|
|
40
|
-
| **Saturation** | "Quão cheio" o serviço está — % do recurso mais escasso | ObservableGauge (%) | Por resource (connection pool, queue, CPU) |
|
|
41
|
-
|
|
42
|
-
### Pattern: instrumentação canônica em OTel SDK (TypeScript/Deno)
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
// PT-BR: 4 golden signals em Edge Function — copiar este shape
|
|
46
|
-
import { trace, metrics } from '@opentelemetry/api'
|
|
47
|
-
|
|
48
|
-
const tracer = trace.getTracer('orders-service')
|
|
49
|
-
const meter = metrics.getMeter('orders-service')
|
|
50
|
-
|
|
51
|
-
// PT-BR: 1. LATENCY — histogram bucketed exponencial
|
|
52
|
-
const latencyHistogram = meter.createHistogram('http_request_duration_ms', {
|
|
53
|
-
description: 'Request latency in ms — split by result',
|
|
54
|
-
unit: 'ms',
|
|
55
|
-
advice: { explicitBucketBoundaries: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000] }
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
// PT-BR: 2. TRAFFIC — counter de requests recebidos
|
|
59
|
-
const trafficCounter = meter.createCounter('http_requests_total', {
|
|
60
|
-
description: 'Total HTTP requests received'
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// PT-BR: 3. ERRORS — counter por error.type (categoria, não message)
|
|
64
|
-
const errorsCounter = meter.createCounter('http_errors_total', {
|
|
65
|
-
description: 'Total HTTP errors by error.type'
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
// PT-BR: 4. SATURATION — gauge do recurso mais escasso
|
|
69
|
-
const saturationGauge = meter.createObservableGauge('db_connection_pool_used_pct', {
|
|
70
|
-
description: 'DB connection pool utilization %',
|
|
71
|
-
unit: '%'
|
|
72
|
-
})
|
|
73
|
-
saturationGauge.addCallback((result) => {
|
|
74
|
-
// PT-BR: callback executado em scrape — lê estado atual do pool
|
|
75
|
-
result.observe(getConnectionPoolUsedPct(), { resource: 'db_pool', service: 'orders' })
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
export async function placeOrder(req: Request) {
|
|
79
|
-
const startMs = performance.now()
|
|
80
|
-
const dims = { endpoint: '/api/v1/orders', method: 'POST' }
|
|
81
|
-
|
|
82
|
-
// PT-BR: 2. Traffic — incrementar antes de processar
|
|
83
|
-
trafficCounter.add(1, dims)
|
|
84
|
-
|
|
85
|
-
return tracer.startActiveSpan('place_order', async (span) => {
|
|
86
|
-
try {
|
|
87
|
-
const order = await db.insertOrder(req.body)
|
|
88
|
-
// PT-BR: 1. Latency success — só após success confirmar
|
|
89
|
-
const durationMs = performance.now() - startMs
|
|
90
|
-
latencyHistogram.record(durationMs, { ...dims, result: 'success' })
|
|
91
|
-
return order
|
|
92
|
-
} catch (e) {
|
|
93
|
-
// PT-BR: 1. Latency error — separada da success
|
|
94
|
-
const durationMs = performance.now() - startMs
|
|
95
|
-
latencyHistogram.record(durationMs, { ...dims, result: 'error' })
|
|
96
|
-
// PT-BR: 3. Errors — counter por error.type (enum baixa cardinalidade)
|
|
97
|
-
errorsCounter.add(1, { ...dims, error_type: classify(e) })
|
|
98
|
-
throw e
|
|
99
|
-
} finally {
|
|
100
|
-
span.end()
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// PT-BR: classifier — enum estável de 5-15 valores
|
|
106
|
-
function classify(e: unknown): string {
|
|
107
|
-
if (e instanceof TimeoutError) return 'timeout'
|
|
108
|
-
if (e instanceof ValidationError) return 'validation'
|
|
109
|
-
if (e instanceof AuthError) return 'auth'
|
|
110
|
-
if (e instanceof RateLimitError) return 'rate_limit'
|
|
111
|
-
if (e instanceof DbError) return 'db'
|
|
112
|
-
return 'unknown'
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Pattern: queries SQL para 4 signals em 1 dashboard
|
|
117
|
-
|
|
118
|
-
```sql
|
|
119
|
-
-- PT-BR: dashboard único — 4 golden signals últimos 60 minutos, por minuto
|
|
120
|
-
select
|
|
121
|
-
date_trunc('minute', timestamp) as minute,
|
|
122
|
-
-- Traffic
|
|
123
|
-
count(*) as traffic_rpm,
|
|
124
|
-
-- Errors (por error.type)
|
|
125
|
-
count(*) filter (where result_success = false) as errors_total,
|
|
126
|
-
count(*) filter (where error_type = 'timeout') as errors_timeout,
|
|
127
|
-
count(*) filter (where error_type = 'rate_limit') as errors_rate_limit,
|
|
128
|
-
count(*) filter (where error_type = 'db') as errors_db,
|
|
129
|
-
-- Latency p50/p95/p99 — APENAS success
|
|
130
|
-
percentile_cont(0.50) within group (order by duration_ms)
|
|
131
|
-
filter (where result_success = true) as latency_p50_success,
|
|
132
|
-
percentile_cont(0.95) within group (order by duration_ms)
|
|
133
|
-
filter (where result_success = true) as latency_p95_success,
|
|
134
|
-
percentile_cont(0.99) within group (order by duration_ms)
|
|
135
|
-
filter (where result_success = true) as latency_p99_success,
|
|
136
|
-
-- Latency p99 — APENAS error (visibilidade de error path lentidão)
|
|
137
|
-
percentile_cont(0.99) within group (order by duration_ms)
|
|
138
|
-
filter (where result_success = false) as latency_p99_error,
|
|
139
|
-
-- Saturation (gauge max no minuto)
|
|
140
|
-
max(connection_pool_used_pct) as saturation_pool_max
|
|
141
|
-
from observability.events
|
|
142
|
-
where service = 'orders-api' and timestamp > now() - interval '60 minutes'
|
|
143
|
-
group by minute
|
|
144
|
-
order by minute desc;
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Pattern: black-box probe complementar (synthetic check)
|
|
148
|
-
|
|
149
|
-
```ts
|
|
150
|
-
// PT-BR: black-box monitoring — chamar serviço como cliente externo
|
|
151
|
-
// Roda em CI ou serviço external (uptimerobot, datadog synthetics)
|
|
152
|
-
async function blackBoxProbe(): Promise<{ ok: boolean; durationMs: number }> {
|
|
153
|
-
const startMs = Date.now()
|
|
154
|
-
const r = await fetch('https://api.example.com/api/v1/orders/probe', {
|
|
155
|
-
method: 'POST',
|
|
156
|
-
body: JSON.stringify({ probe: true, sku: 'TEST-001' }),
|
|
157
|
-
headers: { 'X-Probe': 'true' }
|
|
158
|
-
})
|
|
159
|
-
const durationMs = Date.now() - startMs
|
|
160
|
-
// PT-BR: validar resposta — não basta status 200
|
|
161
|
-
const body = await r.json()
|
|
162
|
-
const ok = r.status === 200 && body.order_id != null && durationMs < 1000
|
|
163
|
-
return { ok, durationMs }
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// PT-BR: rodar a cada 30s; alerta se 3 consecutivos falham (debounce contra flake)
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Pattern: saturation por tipo de serviço
|
|
170
|
-
|
|
171
|
-
| Tipo de serviço | Recurso mais escasso | Métrica de saturation |
|
|
172
|
-
|---|---|---|
|
|
173
|
-
| HTTP API stateless | Connection pool DB | `db_connection_pool_used_pct` |
|
|
174
|
-
| API com cache | Memory do cache | `cache_memory_used_pct` |
|
|
175
|
-
| Worker async | Queue depth | `queue_depth_messages` |
|
|
176
|
-
| Edge Function | Concurrency limit Deno | `concurrent_executions_pct` |
|
|
177
|
-
| DB | Tablespace ou WAL | `disk_used_pct`, `wal_lag_bytes` |
|
|
178
|
-
| CPU-bound (encoder, ML) | Load average | `cpu_load_avg_5min` |
|
|
179
|
-
| Network egress | Bandwidth | `egress_bytes_per_sec_pct` |
|
|
180
|
-
|
|
181
|
-
## Anti-patterns
|
|
182
|
-
|
|
183
|
-
### ANTI: mean latency
|
|
184
|
-
|
|
185
|
-
```text
|
|
186
|
-
ANTI: alerta/dashboard com avg(duration_ms) — long tail invisível.
|
|
187
|
-
|
|
188
|
-
PROBLEMA: mean=50ms mas p99=5000ms = UX ruim invisível; cliente enterprise
|
|
189
|
-
(no p99) sofre sem nunca disparar alerta. Mean é puxado para baixo
|
|
190
|
-
por mass de requests rápidos; sinaliza "tudo ok" enquanto 1% dos
|
|
191
|
-
users espera 5s.
|
|
192
|
-
|
|
193
|
-
CERTO: histogram com percentile_cont(0.99); alertar em p99 > target.
|
|
194
|
-
Reportar p50/p95/p99/p99.9 para ver formato da distribuição.
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### ANTI: latência success+error misturadas
|
|
198
|
-
|
|
199
|
-
```text
|
|
200
|
-
ANTI: histogram(duration_ms) sem dimension result.
|
|
201
|
-
|
|
202
|
-
PROBLEMA: falhas rápidas (HTTP 500 em 5ms quando timeout dispara cedo)
|
|
203
|
-
puxam mean/percentis para baixo; mascaram lentidão real de
|
|
204
|
-
requests bem-sucedidos. Dashboard mostra "p99=80ms" mas
|
|
205
|
-
successes reais são 800ms.
|
|
206
|
-
|
|
207
|
-
CERTO: dimension {result: 'success'} vs {result: 'error'} SEMPRE separadas
|
|
208
|
-
em séries distintas. SLI/SLO computado APENAS sobre success path.
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### ANTI: Errors com error.message como dimension
|
|
212
|
-
|
|
213
|
-
```text
|
|
214
|
-
ANTI: errorsCounter.add(1, { error_message: e.message })
|
|
215
|
-
|
|
216
|
-
PROBLEMA: cada mensagem única é uma série temporal; cardinality explosion
|
|
217
|
-
(1M+ séries em horas se message contém timestamps/IDs/random);
|
|
218
|
-
time-series DB OOMs ou throttles; queries lentas/impossíveis;
|
|
219
|
-
custo de armazenamento explode.
|
|
220
|
-
|
|
221
|
-
CERTO: enum error.type com 5-15 valores fixos (timeout, validation, auth,
|
|
222
|
-
rate_limit, db, provider_down, unknown); error.message em
|
|
223
|
-
log/span attribute (não métrica) para debug pontual.
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### ANTI: monitoring causes não symptoms
|
|
227
|
-
|
|
228
|
-
```text
|
|
229
|
-
ANTI: alertar em "CPU > 80% / memory < 10% / threads > N"
|
|
230
|
-
|
|
231
|
-
PROBLEMA: mistura "what" (sintoma user-facing) com "why" (causa interna);
|
|
232
|
-
falsos positivos (cron job legítimo dispara CPU);
|
|
233
|
-
falsos negativos (sistema lento sem CPU alta — saturação em
|
|
234
|
-
connection pool ou rede); on-call paginado por nada e
|
|
235
|
-
incidents reais passam silenciosos.
|
|
236
|
-
|
|
237
|
-
CERTO: alertar em SLO burn rate sobre os 4 signals (event-based,
|
|
238
|
-
customer-impacting); usar CPU/memory como debug context em
|
|
239
|
-
white-box monitoring, não como alert source.
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### ANTI: saturation genérica
|
|
243
|
-
|
|
244
|
-
```text
|
|
245
|
-
ANTI: copiar pattern de saturation de outro serviço sem identificar o
|
|
246
|
-
gargalo real.
|
|
247
|
-
|
|
248
|
-
PROBLEMA: mede CPU em serviço onde gargalo é connection pool; mede memory
|
|
249
|
-
em serviço CPU-bound; saturation alerta nunca dispara antes do
|
|
250
|
-
incident; quando incident acontece, dashboard mostra "saturação
|
|
251
|
-
OK" e ninguém sabe explicar por quê.
|
|
252
|
-
|
|
253
|
-
CERTO: identificar EXPLICITAMENTE o recurso mais escasso (DB pool? queue
|
|
254
|
-
depth? Deno concurrency? tablespace?) ANTES de instrumentar (ver
|
|
255
|
-
Pattern: saturation por tipo de serviço). Cada serviço tem 1 ou 2
|
|
256
|
-
gargalos reais — instrumentar esses, não copiar template.
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### ANTI: black-box only (sem white-box)
|
|
260
|
-
|
|
261
|
-
```text
|
|
262
|
-
ANTI: só prober externo (synthetic check), sem instrumentação interna.
|
|
263
|
-
|
|
264
|
-
PROBLEMA: sabe que "site offline" mas não sabe porquê; debug requer SSH
|
|
265
|
-
em prod / log dive sem instrumentation; MTTR cresce horas;
|
|
266
|
-
incidents repetem porque root cause nunca foi capturada.
|
|
267
|
-
|
|
268
|
-
CERTO: black-box detecta UX impact (cliente real não consegue) + white-box
|
|
269
|
-
(4 signals) explica root cause. Os dois juntos: black-box dispara,
|
|
270
|
-
white-box mostra qual signal degradou (latency? errors? saturation?)
|
|
271
|
-
e em qual endpoint.
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## Verificação
|
|
275
|
-
|
|
276
|
-
Antes de marcar instrumentação como production-ready, validar:
|
|
277
|
-
|
|
278
|
-
1. **Os 4 signals presentes** — Latency (histogram), Traffic (counter), Errors (counter por error.type), Saturation (gauge resource-specific)
|
|
279
|
-
2. **Latency separada** — `result: 'success'` e `result: 'error'` em séries distintas
|
|
280
|
-
3. **Histogram com bucketing exponencial** — não fixed buckets lineares
|
|
281
|
-
4. **error.type é enum (5-15 valores)** — não `error.message` como dimension
|
|
282
|
-
5. **Saturation tem o recurso certo identificado** — connection pool? queue depth? concurrency? CPU load?
|
|
283
|
-
6. **Black-box probe complementar** — synthetic check do happy path principal a cada 30s
|
|
284
|
-
7. **Dashboard de 4 signals** existe e é o **primeiro** lugar de debug em incident
|
|
285
|
-
|
|
286
|
-
## Saturation as cascading failure trigger (v1.11)
|
|
287
|
-
|
|
288
|
-
**Saturation > threshold é early warning de cascading failure** (cap 22). Quando ainda há tempo para load shedding manter SLO; quando hit 100%, já está em cascade. Threshold tuning canônico:
|
|
289
|
-
|
|
290
|
-
| Recurso | Warning | Critical | Ação automática |
|
|
291
|
-
|---|---|---|---|
|
|
292
|
-
| **CPU load** | > 70% | > 90% | Load shed; scale up |
|
|
293
|
-
| **Memory used** | > 80% | > 95% | Load shed; OOM protection |
|
|
294
|
-
| **Queue depth (pgmq)** | > 70% capacity | > 90% capacity | Drop oldest; scale consumers |
|
|
295
|
-
| **Connection pool (DB)** | > 70% used | > 90% used | Throttle slow queries; scale pool |
|
|
296
|
-
| **Concurrency limit** | > 80% inflight | > 95% inflight | Reject new (503 + Retry-After) |
|
|
297
|
-
| **File descriptors** | > 70% ulimit | > 90% ulimit | Close idle conns; scale up |
|
|
298
|
-
|
|
299
|
-
**Resposta canônica:** quando saturation > Critical, server-side ativa load shedding (skill `load-shedding-graceful-degradation` v1.11) — retorna 503 + Retry-After ANTES de aceitar request que vai falhar. Coopera com caller-side defesas (skill `retry-strategies` v1.11 — full jitter respeita Retry-After).
|
|
300
|
-
|
|
301
|
-
Cross-ref: `cascading-failures` (v1.11) detalha 5 triggers; `cascading-failures-auditor` (v1.11) detecta gaps em código.
|
|
302
|
-
|
|
303
|
-
## Ver também
|
|
304
|
-
|
|
305
|
-
- [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — termos canônicos golden signals, black-box, white-box, percentile
|
|
306
|
-
- [`opentelemetry-standard`](../opentelemetry-standard/SKILL.md) (v1.9) — OTel SDK base, exporter, OTLP
|
|
307
|
-
- [`structured-events`](../structured-events/SKILL.md) (v1.9) — wide events que alimentam SLI de Errors
|
|
308
|
-
- [`event-based-slos`](../event-based-slos/SKILL.md) (v1.9) — SLO sobre Errors+Latency forma SLI canônico
|
|
309
|
-
- [`burn-rate-alerting`](../burn-rate-alerting/SKILL.md) (v1.9) — alertar em SLO burn-rate, não em CPU
|
|
310
|
-
- [`production-readiness-review`](../production-readiness-review/SKILL.md) — PRR axis "Instrumentation" exige 4 signals
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
*Material-fonte: Site Reliability Engineering — Beyer, Jones, Petoff, Murphy (Google/O'Reilly, 2016) — Cap 6: "Monitoring Distributed Systems" (Four Golden Signals).*
|
|
1
|
+
---
|
|
2
|
+
name: four-golden-signals
|
|
3
|
+
description: Use ao instrumentar serviço user-facing — Latency + Traffic + Errors + Saturation, percentis (não mean), histogram exponencial, latência success vs error separadas.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SRE — Four Golden Signals
|
|
7
|
+
|
|
8
|
+
## Quando usar
|
|
9
|
+
|
|
10
|
+
LLM carrega esta skill ao instrumentar Edge Function/serviço/microservice user-facing. Trigger phrases:
|
|
11
|
+
|
|
12
|
+
- "golden signals", "4 sinais dourados"
|
|
13
|
+
- "latency, traffic, errors, saturation"
|
|
14
|
+
- "instrumentar serviço", "métricas mínimas"
|
|
15
|
+
- "p99 latency", "percentis vs mean"
|
|
16
|
+
- "black-box vs white-box monitoring"
|
|
17
|
+
- "Google SRE cap 6"
|
|
18
|
+
- "Latency success vs error"
|
|
19
|
+
|
|
20
|
+
## Regras absolutas
|
|
21
|
+
|
|
22
|
+
- **4 sinais são universais para serviço user-facing** — Latency + Traffic + Errors + Saturation. Se mede esses 4, captura ~95% da saúde operacional. Outros sinais (CPU, memória, disco I/O) são **causas potenciais**, não sintomas — vão em white-box monitoring secundário.
|
|
23
|
+
- **Latency success vs error sempre separadas** — falhas rápidas (HTTP 500 em 5ms) mascaram latência ruim de successes se misturadas. Sempre `histogram(duration_ms, {result: 'success'})` e `histogram(duration_ms, {result: 'error'})` em séries distintas.
|
|
24
|
+
- **NUNCA mean para latency** — long tail invisível: mean=50ms mas p99=5000ms é UX ruim para 1% dos usuários (tipicamente os mais valiosos: enterprise tier). SEMPRE histogram com percentis.
|
|
25
|
+
- **Histogram com bucketing exponencial** — buckets `[1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000]` ms ou base 1.5/2. Captura long tail sem cardinality explosion.
|
|
26
|
+
- **Errors counter por error.type (não message)** — `error.type` enumerado (5-15 valores: `timeout`, `validation`, `auth`, `rate_limit`, `db`, `provider_down`, ...). `error.message` é alta cardinalidade — não usar como dimension.
|
|
27
|
+
- **Saturation é resource-specific** — não existe métrica genérica de saturação. Para HTTP service: connection pool used %. Para DB: tablespace used %. Para queue: queue depth. Para CPU-bound: load average. Identificar O recurso mais escasso ANTES de instrumentar.
|
|
28
|
+
- **Black-box monitora UX, white-box monitora internals** — black-box (synthetic prober HTTP) detecta "site offline" mesmo se métricas internas estão verdes (corner case clássico). White-box (golden signals) explica "porquê" quando black-box dispara.
|
|
29
|
+
- **Reportar p50, p95, p99, p99.9 — não só p99** — p50 (mediana) é UX típica; p95 é primeiro deslize; p99 é cauda; p99.9 é seu 1 em 1000 que é seu cliente enterprise. Cada percentil conta uma história diferente.
|
|
30
|
+
|
|
31
|
+
## Patterns canônicos
|
|
32
|
+
|
|
33
|
+
### Pattern: definição canônica dos 4 signals (tabela)
|
|
34
|
+
|
|
35
|
+
| Signal | Definição | Tipo de instrument | Granularity recomendada |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| **Latency** | Tempo de request bem-sucedido vs falho — SEPARADO | Histogram (ms) com bucketing exponencial | Por endpoint × `result` (success/error) |
|
|
38
|
+
| **Traffic** | Volume de demanda — requests/s, msgs/s, bytes/s | Counter | Por endpoint × method |
|
|
39
|
+
| **Errors** | Taxa de requests que falharam (explícitas: 5xx; implícitas: 200 com payload errado; políticas: > SLO target) | Counter | Por endpoint × `error.type` |
|
|
40
|
+
| **Saturation** | "Quão cheio" o serviço está — % do recurso mais escasso | ObservableGauge (%) | Por resource (connection pool, queue, CPU) |
|
|
41
|
+
|
|
42
|
+
### Pattern: instrumentação canônica em OTel SDK (TypeScript/Deno)
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// PT-BR: 4 golden signals em Edge Function — copiar este shape
|
|
46
|
+
import { trace, metrics } from '@opentelemetry/api'
|
|
47
|
+
|
|
48
|
+
const tracer = trace.getTracer('orders-service')
|
|
49
|
+
const meter = metrics.getMeter('orders-service')
|
|
50
|
+
|
|
51
|
+
// PT-BR: 1. LATENCY — histogram bucketed exponencial
|
|
52
|
+
const latencyHistogram = meter.createHistogram('http_request_duration_ms', {
|
|
53
|
+
description: 'Request latency in ms — split by result',
|
|
54
|
+
unit: 'ms',
|
|
55
|
+
advice: { explicitBucketBoundaries: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000] }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// PT-BR: 2. TRAFFIC — counter de requests recebidos
|
|
59
|
+
const trafficCounter = meter.createCounter('http_requests_total', {
|
|
60
|
+
description: 'Total HTTP requests received'
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
// PT-BR: 3. ERRORS — counter por error.type (categoria, não message)
|
|
64
|
+
const errorsCounter = meter.createCounter('http_errors_total', {
|
|
65
|
+
description: 'Total HTTP errors by error.type'
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// PT-BR: 4. SATURATION — gauge do recurso mais escasso
|
|
69
|
+
const saturationGauge = meter.createObservableGauge('db_connection_pool_used_pct', {
|
|
70
|
+
description: 'DB connection pool utilization %',
|
|
71
|
+
unit: '%'
|
|
72
|
+
})
|
|
73
|
+
saturationGauge.addCallback((result) => {
|
|
74
|
+
// PT-BR: callback executado em scrape — lê estado atual do pool
|
|
75
|
+
result.observe(getConnectionPoolUsedPct(), { resource: 'db_pool', service: 'orders' })
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
export async function placeOrder(req: Request) {
|
|
79
|
+
const startMs = performance.now()
|
|
80
|
+
const dims = { endpoint: '/api/v1/orders', method: 'POST' }
|
|
81
|
+
|
|
82
|
+
// PT-BR: 2. Traffic — incrementar antes de processar
|
|
83
|
+
trafficCounter.add(1, dims)
|
|
84
|
+
|
|
85
|
+
return tracer.startActiveSpan('place_order', async (span) => {
|
|
86
|
+
try {
|
|
87
|
+
const order = await db.insertOrder(req.body)
|
|
88
|
+
// PT-BR: 1. Latency success — só após success confirmar
|
|
89
|
+
const durationMs = performance.now() - startMs
|
|
90
|
+
latencyHistogram.record(durationMs, { ...dims, result: 'success' })
|
|
91
|
+
return order
|
|
92
|
+
} catch (e) {
|
|
93
|
+
// PT-BR: 1. Latency error — separada da success
|
|
94
|
+
const durationMs = performance.now() - startMs
|
|
95
|
+
latencyHistogram.record(durationMs, { ...dims, result: 'error' })
|
|
96
|
+
// PT-BR: 3. Errors — counter por error.type (enum baixa cardinalidade)
|
|
97
|
+
errorsCounter.add(1, { ...dims, error_type: classify(e) })
|
|
98
|
+
throw e
|
|
99
|
+
} finally {
|
|
100
|
+
span.end()
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// PT-BR: classifier — enum estável de 5-15 valores
|
|
106
|
+
function classify(e: unknown): string {
|
|
107
|
+
if (e instanceof TimeoutError) return 'timeout'
|
|
108
|
+
if (e instanceof ValidationError) return 'validation'
|
|
109
|
+
if (e instanceof AuthError) return 'auth'
|
|
110
|
+
if (e instanceof RateLimitError) return 'rate_limit'
|
|
111
|
+
if (e instanceof DbError) return 'db'
|
|
112
|
+
return 'unknown'
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Pattern: queries SQL para 4 signals em 1 dashboard
|
|
117
|
+
|
|
118
|
+
```sql
|
|
119
|
+
-- PT-BR: dashboard único — 4 golden signals últimos 60 minutos, por minuto
|
|
120
|
+
select
|
|
121
|
+
date_trunc('minute', timestamp) as minute,
|
|
122
|
+
-- Traffic
|
|
123
|
+
count(*) as traffic_rpm,
|
|
124
|
+
-- Errors (por error.type)
|
|
125
|
+
count(*) filter (where result_success = false) as errors_total,
|
|
126
|
+
count(*) filter (where error_type = 'timeout') as errors_timeout,
|
|
127
|
+
count(*) filter (where error_type = 'rate_limit') as errors_rate_limit,
|
|
128
|
+
count(*) filter (where error_type = 'db') as errors_db,
|
|
129
|
+
-- Latency p50/p95/p99 — APENAS success
|
|
130
|
+
percentile_cont(0.50) within group (order by duration_ms)
|
|
131
|
+
filter (where result_success = true) as latency_p50_success,
|
|
132
|
+
percentile_cont(0.95) within group (order by duration_ms)
|
|
133
|
+
filter (where result_success = true) as latency_p95_success,
|
|
134
|
+
percentile_cont(0.99) within group (order by duration_ms)
|
|
135
|
+
filter (where result_success = true) as latency_p99_success,
|
|
136
|
+
-- Latency p99 — APENAS error (visibilidade de error path lentidão)
|
|
137
|
+
percentile_cont(0.99) within group (order by duration_ms)
|
|
138
|
+
filter (where result_success = false) as latency_p99_error,
|
|
139
|
+
-- Saturation (gauge max no minuto)
|
|
140
|
+
max(connection_pool_used_pct) as saturation_pool_max
|
|
141
|
+
from observability.events
|
|
142
|
+
where service = 'orders-api' and timestamp > now() - interval '60 minutes'
|
|
143
|
+
group by minute
|
|
144
|
+
order by minute desc;
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Pattern: black-box probe complementar (synthetic check)
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
// PT-BR: black-box monitoring — chamar serviço como cliente externo
|
|
151
|
+
// Roda em CI ou serviço external (uptimerobot, datadog synthetics)
|
|
152
|
+
async function blackBoxProbe(): Promise<{ ok: boolean; durationMs: number }> {
|
|
153
|
+
const startMs = Date.now()
|
|
154
|
+
const r = await fetch('https://api.example.com/api/v1/orders/probe', {
|
|
155
|
+
method: 'POST',
|
|
156
|
+
body: JSON.stringify({ probe: true, sku: 'TEST-001' }),
|
|
157
|
+
headers: { 'X-Probe': 'true' }
|
|
158
|
+
})
|
|
159
|
+
const durationMs = Date.now() - startMs
|
|
160
|
+
// PT-BR: validar resposta — não basta status 200
|
|
161
|
+
const body = await r.json()
|
|
162
|
+
const ok = r.status === 200 && body.order_id != null && durationMs < 1000
|
|
163
|
+
return { ok, durationMs }
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// PT-BR: rodar a cada 30s; alerta se 3 consecutivos falham (debounce contra flake)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Pattern: saturation por tipo de serviço
|
|
170
|
+
|
|
171
|
+
| Tipo de serviço | Recurso mais escasso | Métrica de saturation |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| HTTP API stateless | Connection pool DB | `db_connection_pool_used_pct` |
|
|
174
|
+
| API com cache | Memory do cache | `cache_memory_used_pct` |
|
|
175
|
+
| Worker async | Queue depth | `queue_depth_messages` |
|
|
176
|
+
| Edge Function | Concurrency limit Deno | `concurrent_executions_pct` |
|
|
177
|
+
| DB | Tablespace ou WAL | `disk_used_pct`, `wal_lag_bytes` |
|
|
178
|
+
| CPU-bound (encoder, ML) | Load average | `cpu_load_avg_5min` |
|
|
179
|
+
| Network egress | Bandwidth | `egress_bytes_per_sec_pct` |
|
|
180
|
+
|
|
181
|
+
## Anti-patterns
|
|
182
|
+
|
|
183
|
+
### ANTI: mean latency
|
|
184
|
+
|
|
185
|
+
```text
|
|
186
|
+
ANTI: alerta/dashboard com avg(duration_ms) — long tail invisível.
|
|
187
|
+
|
|
188
|
+
PROBLEMA: mean=50ms mas p99=5000ms = UX ruim invisível; cliente enterprise
|
|
189
|
+
(no p99) sofre sem nunca disparar alerta. Mean é puxado para baixo
|
|
190
|
+
por mass de requests rápidos; sinaliza "tudo ok" enquanto 1% dos
|
|
191
|
+
users espera 5s.
|
|
192
|
+
|
|
193
|
+
CERTO: histogram com percentile_cont(0.99); alertar em p99 > target.
|
|
194
|
+
Reportar p50/p95/p99/p99.9 para ver formato da distribuição.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### ANTI: latência success+error misturadas
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
ANTI: histogram(duration_ms) sem dimension result.
|
|
201
|
+
|
|
202
|
+
PROBLEMA: falhas rápidas (HTTP 500 em 5ms quando timeout dispara cedo)
|
|
203
|
+
puxam mean/percentis para baixo; mascaram lentidão real de
|
|
204
|
+
requests bem-sucedidos. Dashboard mostra "p99=80ms" mas
|
|
205
|
+
successes reais são 800ms.
|
|
206
|
+
|
|
207
|
+
CERTO: dimension {result: 'success'} vs {result: 'error'} SEMPRE separadas
|
|
208
|
+
em séries distintas. SLI/SLO computado APENAS sobre success path.
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### ANTI: Errors com error.message como dimension
|
|
212
|
+
|
|
213
|
+
```text
|
|
214
|
+
ANTI: errorsCounter.add(1, { error_message: e.message })
|
|
215
|
+
|
|
216
|
+
PROBLEMA: cada mensagem única é uma série temporal; cardinality explosion
|
|
217
|
+
(1M+ séries em horas se message contém timestamps/IDs/random);
|
|
218
|
+
time-series DB OOMs ou throttles; queries lentas/impossíveis;
|
|
219
|
+
custo de armazenamento explode.
|
|
220
|
+
|
|
221
|
+
CERTO: enum error.type com 5-15 valores fixos (timeout, validation, auth,
|
|
222
|
+
rate_limit, db, provider_down, unknown); error.message em
|
|
223
|
+
log/span attribute (não métrica) para debug pontual.
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### ANTI: monitoring causes não symptoms
|
|
227
|
+
|
|
228
|
+
```text
|
|
229
|
+
ANTI: alertar em "CPU > 80% / memory < 10% / threads > N"
|
|
230
|
+
|
|
231
|
+
PROBLEMA: mistura "what" (sintoma user-facing) com "why" (causa interna);
|
|
232
|
+
falsos positivos (cron job legítimo dispara CPU);
|
|
233
|
+
falsos negativos (sistema lento sem CPU alta — saturação em
|
|
234
|
+
connection pool ou rede); on-call paginado por nada e
|
|
235
|
+
incidents reais passam silenciosos.
|
|
236
|
+
|
|
237
|
+
CERTO: alertar em SLO burn rate sobre os 4 signals (event-based,
|
|
238
|
+
customer-impacting); usar CPU/memory como debug context em
|
|
239
|
+
white-box monitoring, não como alert source.
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### ANTI: saturation genérica
|
|
243
|
+
|
|
244
|
+
```text
|
|
245
|
+
ANTI: copiar pattern de saturation de outro serviço sem identificar o
|
|
246
|
+
gargalo real.
|
|
247
|
+
|
|
248
|
+
PROBLEMA: mede CPU em serviço onde gargalo é connection pool; mede memory
|
|
249
|
+
em serviço CPU-bound; saturation alerta nunca dispara antes do
|
|
250
|
+
incident; quando incident acontece, dashboard mostra "saturação
|
|
251
|
+
OK" e ninguém sabe explicar por quê.
|
|
252
|
+
|
|
253
|
+
CERTO: identificar EXPLICITAMENTE o recurso mais escasso (DB pool? queue
|
|
254
|
+
depth? Deno concurrency? tablespace?) ANTES de instrumentar (ver
|
|
255
|
+
Pattern: saturation por tipo de serviço). Cada serviço tem 1 ou 2
|
|
256
|
+
gargalos reais — instrumentar esses, não copiar template.
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### ANTI: black-box only (sem white-box)
|
|
260
|
+
|
|
261
|
+
```text
|
|
262
|
+
ANTI: só prober externo (synthetic check), sem instrumentação interna.
|
|
263
|
+
|
|
264
|
+
PROBLEMA: sabe que "site offline" mas não sabe porquê; debug requer SSH
|
|
265
|
+
em prod / log dive sem instrumentation; MTTR cresce horas;
|
|
266
|
+
incidents repetem porque root cause nunca foi capturada.
|
|
267
|
+
|
|
268
|
+
CERTO: black-box detecta UX impact (cliente real não consegue) + white-box
|
|
269
|
+
(4 signals) explica root cause. Os dois juntos: black-box dispara,
|
|
270
|
+
white-box mostra qual signal degradou (latency? errors? saturation?)
|
|
271
|
+
e em qual endpoint.
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Verificação
|
|
275
|
+
|
|
276
|
+
Antes de marcar instrumentação como production-ready, validar:
|
|
277
|
+
|
|
278
|
+
1. **Os 4 signals presentes** — Latency (histogram), Traffic (counter), Errors (counter por error.type), Saturation (gauge resource-specific)
|
|
279
|
+
2. **Latency separada** — `result: 'success'` e `result: 'error'` em séries distintas
|
|
280
|
+
3. **Histogram com bucketing exponencial** — não fixed buckets lineares
|
|
281
|
+
4. **error.type é enum (5-15 valores)** — não `error.message` como dimension
|
|
282
|
+
5. **Saturation tem o recurso certo identificado** — connection pool? queue depth? concurrency? CPU load?
|
|
283
|
+
6. **Black-box probe complementar** — synthetic check do happy path principal a cada 30s
|
|
284
|
+
7. **Dashboard de 4 signals** existe e é o **primeiro** lugar de debug em incident
|
|
285
|
+
|
|
286
|
+
## Saturation as cascading failure trigger (v1.11)
|
|
287
|
+
|
|
288
|
+
**Saturation > threshold é early warning de cascading failure** (cap 22). Quando ainda há tempo para load shedding manter SLO; quando hit 100%, já está em cascade. Threshold tuning canônico:
|
|
289
|
+
|
|
290
|
+
| Recurso | Warning | Critical | Ação automática |
|
|
291
|
+
|---|---|---|---|
|
|
292
|
+
| **CPU load** | > 70% | > 90% | Load shed; scale up |
|
|
293
|
+
| **Memory used** | > 80% | > 95% | Load shed; OOM protection |
|
|
294
|
+
| **Queue depth (pgmq)** | > 70% capacity | > 90% capacity | Drop oldest; scale consumers |
|
|
295
|
+
| **Connection pool (DB)** | > 70% used | > 90% used | Throttle slow queries; scale pool |
|
|
296
|
+
| **Concurrency limit** | > 80% inflight | > 95% inflight | Reject new (503 + Retry-After) |
|
|
297
|
+
| **File descriptors** | > 70% ulimit | > 90% ulimit | Close idle conns; scale up |
|
|
298
|
+
|
|
299
|
+
**Resposta canônica:** quando saturation > Critical, server-side ativa load shedding (skill `load-shedding-graceful-degradation` v1.11) — retorna 503 + Retry-After ANTES de aceitar request que vai falhar. Coopera com caller-side defesas (skill `retry-strategies` v1.11 — full jitter respeita Retry-After).
|
|
300
|
+
|
|
301
|
+
Cross-ref: `cascading-failures` (v1.11) detalha 5 triggers; `cascading-failures-auditor` (v1.11) detecta gaps em código.
|
|
302
|
+
|
|
303
|
+
## Ver também
|
|
304
|
+
|
|
305
|
+
- [`_shared-sre/glossary.md`](../_shared-sre/glossary.md) — termos canônicos golden signals, black-box, white-box, percentile
|
|
306
|
+
- [`opentelemetry-standard`](../opentelemetry-standard/SKILL.md) (v1.9) — OTel SDK base, exporter, OTLP
|
|
307
|
+
- [`structured-events`](../structured-events/SKILL.md) (v1.9) — wide events que alimentam SLI de Errors
|
|
308
|
+
- [`event-based-slos`](../event-based-slos/SKILL.md) (v1.9) — SLO sobre Errors+Latency forma SLI canônico
|
|
309
|
+
- [`burn-rate-alerting`](../burn-rate-alerting/SKILL.md) (v1.9) — alertar em SLO burn-rate, não em CPU
|
|
310
|
+
- [`production-readiness-review`](../production-readiness-review/SKILL.md) — PRR axis "Instrumentation" exige 4 signals
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
*Material-fonte: Site Reliability Engineering — Beyer, Jones, Petoff, Murphy (Google/O'Reilly, 2016) — Cap 6: "Monitoring Distributed Systems" (Four Golden Signals).*
|