mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 22:15:51 +00:00
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>
This commit is contained in:
parent
c1029de875
commit
dc02d49bf1
@ -48,6 +48,7 @@
|
||||
req("/debug/metrics"): handleC2NDebugMetrics,
|
||||
req("/debug/component-logging"): handleC2NDebugComponentLogging,
|
||||
req("/debug/logheap"): handleC2NDebugLogHeap,
|
||||
req("/debug/logallocs"): handleC2NDebugLogAllocs,
|
||||
req("POST /logtail/flush"): handleC2NLogtailFlush,
|
||||
req("POST /sockstats"): handleC2NSockStats,
|
||||
|
||||
@ -175,9 +176,22 @@ func handleC2NDebugLogHeap(b *LocalBackend, w http.ResponseWriter, r *http.Reque
|
||||
http.Error(w, "not implemented", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
runtime.GC()
|
||||
c2nLogHeap(w, r)
|
||||
}
|
||||
|
||||
var c2nLogAllocs func(http.ResponseWriter, *http.Request) // non-nil on most platforms (c2n_pprof.go)
|
||||
|
||||
func handleC2NDebugLogAllocs(b *LocalBackend, w http.ResponseWriter, r *http.Request) {
|
||||
if c2nLogAllocs == nil {
|
||||
// Not implemented on platforms trying to optimize for binary size or
|
||||
// reduced memory usage.
|
||||
http.Error(w, "not implemented", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
c2nLogAllocs(w, r)
|
||||
}
|
||||
|
||||
func handleC2NSSHUsernames(b *LocalBackend, w http.ResponseWriter, r *http.Request) {
|
||||
var req tailcfg.C2NSSHUsernamesRequest
|
||||
if r.Method == "POST" {
|
||||
|
@ -14,4 +14,8 @@ 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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user