github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/agent/gospy/gospy_test.go (about) 1 package gospy 2 3 import ( 4 "log" 5 "time" 6 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 "github.com/pyroscope-io/pyroscope/pkg/agent/spy" 10 "github.com/pyroscope-io/pyroscope/pkg/config" 11 "github.com/pyroscope-io/pyroscope/pkg/testing" 12 ) 13 14 var _ = Describe("analytics", func() { 15 testing.WithConfig(func(cfg **config.Config) { 16 Describe("NewSession", func() { 17 It("works as expected", func(done Done) { 18 params := spy.InitParams{ProfileType: spy.ProfileCPU, SampleRate: 100} 19 s, err := Start(params) 20 Expect(err).ToNot(HaveOccurred()) 21 go func() { 22 s := time.Now() 23 i := 0 24 for time.Now().Sub(s) < 300*time.Millisecond { 25 i++ 26 time.Sleep(1 * time.Nanosecond) 27 } 28 }() 29 30 time.Sleep(50 * time.Millisecond) 31 s.Snapshot(func(labels *spy.Labels, name []byte, samples uint64) error { 32 log.Println("name", string(name)) 33 return nil 34 }) 35 close(done) 36 }) 37 }) 38 }) 39 })