Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions listener/src/api/events-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,15 @@ export function createEventsServer(options: EventsServerOptions): http.Server {
res.setHeader('X-Request-Id', requestId);
res.setHeader('X-Correlation-Id', correlationId);

if (rateLimiter) {
const url = new URL(req.url ?? '/', 'http://localhost');

// The rate-limit metrics endpoint is an observability route and must stay
// reachable even after a client exhausts its quota — otherwise callers
// can't read the very metrics that explain why they are being throttled.
const isRateLimitExempt =
req.method === 'GET' && url.pathname === '/api/rate-limit/metrics';

if (rateLimiter && !isRateLimitExempt) {
const allowed = await rateLimiter.handle(req, res as any);
if (!allowed) return;
}
Expand All @@ -167,8 +175,6 @@ export function createEventsServer(options: EventsServerOptions): http.Server {
return;
}

const url = new URL(req.url ?? '/', 'http://localhost');

// GET /health
if (req.method === 'GET' && url.pathname === '/health') {
buildHealthResponse(options).then((health) => {
Expand Down
Loading