Fetch a goroutine dump from the pprof endpoint
curl -q http://myapp.com:<port>/debug/pprof/goroutine?debug=2 > goroutine.dump
Install ansicolor gem
gem install term-ansicolor
Turn the hard to read output into easier to consume JSON
ruby stack_dump_parser.rb goroutine.dump
require_relative './stack_dump_parser.rb'
parser = StackDumpParser.new('goroutine.dump')
# print out all goroutines with a function matching /Execute/ in the stack
puts parser.goroutines.select { |goroutine| goroutine.in_stack? /Execute/ }.map(&:raw)
# put count of goroutines in each state
puts parser.goroutines.group_by(&:state).map { |(state, filtered_goroutines)| sprintf("%03d - %s", filtered_goroutines.length, state) }.sort