feat: Add basic metrics via expvar to health server
This commit implements basic application metrics via the `expvar` package by exposing it on the `/debug/vars` endpoint within the custom HTTP server in `pkg/health/server.go`. It fulfills the "Basic Metrics Implementation" requirement under the "Ultimate Visibility" framework. The `docs/design/ETL_TODO.md` documentation has also been updated to mark this task as completed. Co-authored-by: hobbyistlabs-coder <267281733+hobbyistlabs-coder@users.noreply.github.com>
This commit is contained in:
parent
a2c9e1ebcb
commit
3f412ab1ea
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)
|
## 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).
|
- [ ] **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] **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.
|
- [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).
|
- [ ] **AgentLoop Telemetry:** Add specific instrumentation to the `AgentLoop` (iteration duration, tool execution duration, failure counts).
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package health
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"expvar"
|
||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -41,6 +42,7 @@ func NewServer(host string, port int) *Server {
|
||||||
|
|
||||||
mux.HandleFunc("/health", s.healthHandler)
|
mux.HandleFunc("/health", s.healthHandler)
|
||||||
mux.HandleFunc("/ready", s.readyHandler)
|
mux.HandleFunc("/ready", s.readyHandler)
|
||||||
|
mux.Handle("/debug/vars", expvar.Handler())
|
||||||
|
|
||||||
addr := fmt.Sprintf("%s:%d", host, port)
|
addr := fmt.Sprintf("%s:%d", host, port)
|
||||||
s.server = &http.Server{
|
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) {
|
func (s *Server) RegisterOnMux(mux *http.ServeMux) {
|
||||||
mux.HandleFunc("/health", s.healthHandler)
|
mux.HandleFunc("/health", s.healthHandler)
|
||||||
mux.HandleFunc("/ready", s.readyHandler)
|
mux.HandleFunc("/ready", s.readyHandler)
|
||||||
|
mux.Handle("/debug/vars", expvar.Handler())
|
||||||
}
|
}
|
||||||
|
|
||||||
func statusString(ok bool) string {
|
func statusString(ok bool) string {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue