Create stats endpoint - #1
Merged
Merged
Conversation
…lth check endpoint
There was a problem hiding this comment.
Pull request overview
This PR adds a statistics endpoint (/stats) to the load balancer that exposes backend server health metrics including uptime and memory usage. The implementation replaces the simulated traefik/whoami backends with custom Go servers that expose a /health endpoint for metrics collection.
Key changes:
- Implemented a
/statsendpoint that returns JSON with per-backend status, uptime, and memory usage - Added health metric collection from backend servers every 20 seconds during health checks
- Replaced Docker Compose backend services with custom Go servers that expose runtime statistics
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| docker-compose.yml | Replaced traefik/whoami images with custom Go backend servers built from Dockerfile.backend |
| Dockerfile.backend | New Dockerfile for building the custom backend server with health endpoint |
| Dockerfile | Updated build command to build all files in cmd/lb directory instead of just main.go |
| cmd/server/main.go | New backend server implementation with /health endpoint that reports memory usage |
| cmd/lb/main.go | Added stats collection from backend /health endpoints and registered /stats handler |
| cmd/lb/stats.go | New stats handler that returns JSON statistics for all backends |
| core/backend.go | Added uptime tracking, memory usage fields, and helper methods for formatting statistics |
| core/pool.go | Added pool-level statistics aggregation methods and duration formatting utilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.