github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/agent/dotnetspy/dotnetspy.go (about) 1 //go:build dotnetspy 2 // +build dotnetspy 3 4 package dotnetspy 5 6 import ( 7 "github.com/pyroscope-io/pyroscope/pkg/agent/spy" 8 ) 9 10 type DotnetSpy struct { 11 session *session 12 reset bool 13 } 14 15 func init() { 16 spy.RegisterSpy("dotnetspy", Start) 17 } 18 19 func Start(params spy.InitParams) (spy.Spy, error) { 20 s := newSession(params.Pid) 21 _ = s.start() 22 return &DotnetSpy{session: s}, nil 23 } 24 25 func (s *DotnetSpy) Stop() error { 26 return s.session.stop() 27 } 28 29 func (s *DotnetSpy) Reset() { 30 s.reset = true 31 } 32 33 func (s *DotnetSpy) Snapshot(cb func(*spy.Labels, []byte, uint64) error) error { 34 if !s.reset { 35 return nil 36 } 37 s.reset = false 38 return s.session.flush(func(name []byte, v uint64) error { 39 return cb(nil, name, v) 40 }) 41 }