(key: string)
| 32 | } |
| 33 | |
| 34 | function shouldAlert(key: string): boolean { |
| 35 | const now = Date.now(); |
| 36 | const last = alertCooldowns.get(key); |
| 37 | if (last && now - last < ALERT_COOLDOWN_MS) return false; |
| 38 | alertCooldowns.set(key, now); |
| 39 | if (alertCooldowns.size > MAX_COOLDOWN_ENTRIES) { |
| 40 | const cutoff = now - ALERT_COOLDOWN_MS; |
| 41 | for (const [k, t] of alertCooldowns) { |
| 42 | if (t < cutoff) alertCooldowns.delete(k); |
| 43 | } |
| 44 | } |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | function notifySlack(method: string, path: string, durationMs: number, status: number): void { |
| 49 | if (!OPS_ALERT_CHANNEL_ID || !isSlackConfigured()) return; |
no test coverage detected