tailscale/ipn/ipnlocal/c2n_pprof.go
Percy Wegmann dc02d49bf1
ipn/ipnlocal/c2n: add logallocs endpoint
This allows C2N clients to obtain sampled information about
memory allocations since the program started.

We now also force GC on logheap.

Updates tailscale/corp#18514

Signed-off-by: Percy Wegmann <percy@tailscale.com>
2024-03-21 07:26:20 -05:00

22 lines
381 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:build !js && !wasm
package ipnlocal
import (
"net/http"
"runtime/pprof"
)
func init() {
c2nLogHeap = func(w http.ResponseWriter, r *http.Request) {
pprof.WriteHeapProfile(w)
}
c2nLogAllocs = func(w http.ResponseWriter, r *http.Request) {
pprof.Lookup("allocs").WriteTo(w, 0)
}
}