From f9e07d6143dc8a91f33dd966fc8b469c6447f229 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Sun, 4 Jun 2023 22:20:46 +0100 Subject: [PATCH] goroutines parser: Add --less flag to filter goroutines (#17339) --- docs/debugging/pprofgoparser/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/debugging/pprofgoparser/main.go b/docs/debugging/pprofgoparser/main.go index becb1d740..692cc2ea0 100644 --- a/docs/debugging/pprofgoparser/main.go +++ b/docs/debugging/pprofgoparser/main.go @@ -33,14 +33,15 @@ import ( ) var ( - re *regexp.Regexp - goTime, margin time.Duration + re *regexp.Regexp + goTime, less, margin time.Duration ) func init() { re = regexp.MustCompile(`^goroutine [0-9]+ \[[^,]+(, ([0-9]+) minutes)?\]:$`) - flag.DurationVar(&goTime, "time", 0, "goroutine block age") + flag.DurationVar(&less, "less", 0, "goroutine waiting less than the specified time") + flag.DurationVar(&goTime, "time", 0, "goroutine waiting for exactly the specified time") flag.DurationVar(&margin, "margin", 0, "margin time") } @@ -130,6 +131,9 @@ func main() { fmt.Println("") for t, stacks := range r { + if less != 0 && t >= less { + continue + } if goTime == 0 || math.Abs(float64(t)-float64(goTime)) <= float64(margin) { for _, stack := range stacks { fmt.Println(stack)