github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/agent/debugspy/debugspy.go (about) 1 //go:build debugspy 2 // +build debugspy 3 4 package debugspy 5 6 import ( 7 "fmt" 8 9 "github.com/pyroscope-io/pyroscope/pkg/agent/spy" 10 ) 11 12 type DebugSpy struct { 13 pid int 14 } 15 16 func Start(params spy.InitParams) (spy.Spy, error) { 17 return &DebugSpy{ 18 pid: params.Pid, 19 }, nil 20 } 21 22 func (s *DebugSpy) Stop() error { 23 return nil 24 } 25 26 // Snapshot calls callback function with stack-trace or error. 27 func (s *DebugSpy) Snapshot(cb func(*spy.Labels, []byte, uint64) error) error { 28 stacktrace := fmt.Sprintf("debug_%d;debug", s.pid) 29 return cb(nil, []byte(stacktrace), 1) 30 } 31 32 func init() { 33 spy.RegisterSpy("debugspy", Start) 34 }