MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / shouldAlert

Function shouldAlert

server/src/middleware/slow-response.ts:34–46  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

32}
33
34function 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
48function notifySlack(method: string, path: string, durationMs: number, status: number): void {
49 if (!OPS_ALERT_CHANNEL_ID || !isSlackConfigured()) return;

Callers 1

slowResponseTrackerFunction · 0.85

Calls 4

nowMethod · 0.80
deleteMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected