Skip to content

Commit 3a5ab3e

Browse files
authored
chore: add fgprof handler (#114)
1 parent 074b1f6 commit 3a5ab3e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.0
1414
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee
1515
github.com/cep21/circuit/v3 v3.2.2
16+
github.com/felixge/fgprof v0.9.5
1617
github.com/golang/mock v1.6.0
1718
github.com/google/uuid v1.6.0
1819
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1
@@ -61,7 +62,6 @@ require (
6162
github.com/beorn7/perks v1.0.1 // indirect
6263
github.com/cespare/xxhash/v2 v2.3.0 // indirect
6364
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
64-
github.com/felixge/fgprof v0.9.5 // indirect
6565
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
6666
github.com/google/pprof v0.0.0-20250422154841-e1f9c1950416 // indirect
6767
github.com/mitchellh/mapstructure v1.5.0 // indirect

network/debugserver/debugserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"time"
88

9+
"github.com/felixge/fgprof"
910
"github.com/prometheus/client_golang/prometheus/promhttp"
1011
"go.uber.org/atomic"
1112
"go.uber.org/zap"
@@ -53,6 +54,9 @@ func initHandler(ready *atomic.Bool) http.Handler {
5354
mux.HandleFunc("/live", liveness)
5455
mux.HandleFunc("/ready", readiness(ready))
5556
mux.Handle("/log/level", logger.Handler())
57+
// fgprof can collect CPU profile even for Off-CPU goroutines.
58+
// It's useful for measurement for any operations that force goroutines to block.
59+
mux.Handle("/debug/fgprof", fgprof.Handler())
5660

5761
return mux
5862
}

0 commit comments

Comments
 (0)