feat: per-endpoint SLO monitor - #759
Merged
greatest0fallt1me merged 1 commit intoJul 29, 2026
Merged
Conversation
Contributor
|
Merged into main via admin resolver (-X theirs). |
Contributor
|
Merged ⭐ nicely done |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements per-endpoint SLO monitoring for latency and error rate metrics with alert thresholds, adhering to project styles and guidelines.
Closes #286
Changes
Metrics Registration: Restored missing endpointRequestsTotal (Counter) and endpointRequestDuration (Histogram) metrics to resolve downstream merge conflict errors, and added sloViolationsTotal (Counter).
SLO Monitor Service: Created src/services/sloMonitor.ts to manage in-memory sliding window request logs per endpoint. Evaluates requests against configured limits (using src/config/slo.ts) and increments sloViolationsTotal for breaches.
Middleware Integration: Updated src/middleware/metricsHistogram.ts to sanitize and pass completed request metadata to the SLO Monitor.
Unit Tests: Added focused tests in tests/sloMonitor.test.ts to cover latency thresholds, sliding window sample eviction (simulated using mocked timers), and configuration fallback routing.
Verification & Edge Cases
Test Output
bash
PASS tests/metricsHistogram.test.ts
PASS tests/sloMonitor.test.ts
Test Suites: 2 passed, 2 total
Tests: 16 passed, 16 total
Snapshots: 0 total
Time: 30.926 s
ESLint Output
bash
$ npx eslint src/config/slo.ts src/services/sloMonitor.ts src/metrics/registry.ts src/middleware/metricsHistogram.ts
(0 errors, 0 warnings)