github.com/grafana/pyroscope@v1.18.0/pkg/phlaredb/symdb/resolver_pprof_full.go (about) 1 package symdb 2 3 import ( 4 googlev1 "github.com/grafana/pyroscope/api/gen/proto/go/google/v1" 5 schemav1 "github.com/grafana/pyroscope/pkg/phlaredb/schemas/v1" 6 ) 7 8 type pprofFull struct { 9 profile googlev1.Profile 10 symbols *Symbols 11 samples *schemav1.Samples 12 lut []uint32 13 cur int 14 } 15 16 func (r *pprofFull) init(symbols *Symbols, samples schemav1.Samples) { 17 r.symbols = symbols 18 r.samples = &samples 19 r.profile.Sample = make([]*googlev1.Sample, samples.Len()) 20 } 21 22 func (r *pprofFull) InsertStacktrace(_ uint32, locations []int32) { 23 s := &googlev1.Sample{ 24 LocationId: make([]uint64, len(locations)), 25 Value: []int64{int64(r.samples.Values[r.cur])}, 26 } 27 for i, v := range locations { 28 s.LocationId[i] = uint64(v) 29 } 30 r.profile.Sample[r.cur] = s 31 r.cur++ 32 } 33 34 func (r *pprofFull) buildPprof() *googlev1.Profile { 35 createSampleTypeStub(&r.profile) 36 if r.symbols != nil { 37 copyLocations(&r.profile, r.symbols, r.lut) 38 copyFunctions(&r.profile, r.symbols, r.lut) 39 copyMappings(&r.profile, r.symbols, r.lut) 40 copyStrings(&r.profile, r.symbols, r.lut) 41 } 42 return &r.profile 43 }