Skip to content

Create stats endpoint - #1

Merged
P4ST4S merged 11 commits into
mainfrom
create-stats-endpoint
Nov 26, 2025
Merged

Create stats endpoint#1
P4ST4S merged 11 commits into
mainfrom
create-stats-endpoint

Conversation

@P4ST4S

@P4ST4S P4ST4S commented Nov 26, 2025

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /stats endpoint 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.

Comment thread core/pool.go
Comment thread core/pool.go
Comment thread cmd/lb/main.go
Comment thread cmd/lb/main.go
Comment thread cmd/lb/stats.go Outdated
Comment thread cmd/lb/main.go
Comment thread cmd/lb/main.go Outdated
@P4ST4S
P4ST4S merged commit f1fa8b7 into main Nov 26, 2025
1 check failed
@P4ST4S
P4ST4S deleted the create-stats-endpoint branch November 26, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants