Skip to content

Conversation

@LaurenceJJones
Copy link
Member

Refactor Prometheus server to match pprof pattern:

  • Use dedicated http.ServeMux instead of default mux
  • Manage server lifecycle with errgroup
  • Add graceful shutdown handler with 5s timeout
  • Proper error propagation instead of fire-and-forget goroutine

This ensures the Prometheus server shuts down cleanly on SIGTERM/SIGINT and errors are properly tracked by the errgroup.

Refactor Prometheus server to match pprof pattern:
- Use dedicated http.ServeMux instead of default mux
- Manage server lifecycle with errgroup
- Add graceful shutdown handler with 5s timeout
- Proper error propagation instead of fire-and-forget goroutine

This ensures the Prometheus server shuts down cleanly on SIGTERM/SIGINT
and errors are properly tracked by the errgroup.
@LaurenceJJones LaurenceJJones changed the title fix: add graceful shutdown for Prometheus metrics server fix(prometheus): add graceful shutdown for server Dec 3, 2025
@LaurenceJJones LaurenceJJones added this to the 0.3.0 milestone Dec 3, 2025
Copilot finished reviewing on behalf of LaurenceJJones December 3, 2025 16:23
Copy link
Contributor

Copilot AI left a comment

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 refactors the Prometheus metrics server to match the established pprof server pattern, ensuring consistent server lifecycle management across the codebase. The change replaces a fire-and-forget goroutine with proper errgroup-based lifecycle management and graceful shutdown handling.

Key Changes

  • Replaced default HTTP mux with dedicated ServeMux to avoid conflicts
  • Integrated server lifecycle with errgroup for proper error propagation and coordinated shutdown
  • Added graceful shutdown handler that responds to SIGTERM/SIGINT with 5-second timeout

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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