This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 17:36:53 +01:00
1 parent 5b6d4a7903
commit 4d1087e357
160 files changed
+2407 -1933

No files matched your search

-4
View File
@@ -14,14 +14,10 @@ type agentHealthMetrics struct {
OpenFDs *int `json:"open_fds,omitempty"`
}
// agentDiagnostics is an authenticated, on-demand snapshot. No background
// goroutine, accumulating history, or extra public health endpoint is needed.
func agentDiagnostics() agentHealthMetrics {
var memory runtime.MemStats
runtime.ReadMemStats(&memory)
result := agentHealthMetrics{HeapAllocBytes: memory.HeapAlloc, Goroutines: runtime.NumGoroutine()}
// Linux agents expose RSS and descriptor counts in /proc. On unsupported
// platforms omit these fields instead of incorrectly calling heap RSS.
if fields := strings.Fields(readTrimmed("/proc/self/statm")); len(fields) >= 2 {
if resident, err := strconv.ParseUint(fields[1], 10, 64); err == nil {
rss := resident * uint64(os.Getpagesize())