Merge pull request #36 from hobbyistlabs-coder/fix-metrics-todo-9636923013980118550
feat: Add basic metrics via expvar to health server
This commit is contained in:
commit
4566433430
2 changed files with 4 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ This document tracks the tasks required to implement the "Ultimate Visibility" E
|
|||
## 1. Extract (Ingestion & Telemetry Collection)
|
||||
|
||||
- [ ] **Structured Logging:** Ensure `zerolog` is used consistently across the codebase for structured JSON logging. Add context to logs where missing (session IDs, tool inputs/outputs).
|
||||
- [ ] **Basic Metrics Implementation:** Introduce a metrics package (e.g., using `expvar` or a Prometheus client) to expose basic application metrics.
|
||||
- [x] **Basic Metrics Implementation:** Introduce a metrics package (e.g., using `expvar` or a Prometheus client) to expose basic application metrics.
|
||||
- [x] **Goroutine Tracking:** Implement a metric to track the number of active Goroutines.
|
||||
- [x] **Memory Tracking:** Implement a metric to track heap allocation and GC pauses.
|
||||
- [ ] **AgentLoop Telemetry:** Add specific instrumentation to the `AgentLoop` (iteration duration, tool execution duration, failure counts).
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package health
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"expvar"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
|
|
@ -41,6 +42,7 @@ func NewServer(host string, port int) *Server {
|
|||
|
||||
mux.HandleFunc("/health", s.healthHandler)
|
||||
mux.HandleFunc("/ready", s.readyHandler)
|
||||
mux.Handle("/debug/vars", expvar.Handler())
|
||||
|
||||
addr := fmt.Sprintf("%s:%d", host, port)
|
||||
s.server = &http.Server{
|
||||
|
|
@ -162,6 +164,7 @@ func (s *Server) readyHandler(w http.ResponseWriter, r *http.Request) {
|
|||
func (s *Server) RegisterOnMux(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/health", s.healthHandler)
|
||||
mux.HandleFunc("/ready", s.readyHandler)
|
||||
mux.Handle("/debug/vars", expvar.Handler())
|
||||
}
|
||||
|
||||
func statusString(ok bool) string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue