@@ -13,89 +13,86 @@ import (
1313 "go.uber.org/zap/zapcore"
1414)
1515
16- type Profile pprofile.Profile
16+ type Profile struct {
17+ pprofile.Profile
18+ Dictionary pprofile.ProfilesDictionary
19+ }
1720
1821func (p Profile ) MarshalLogObject (encoder zapcore.ObjectEncoder ) error {
19- pp := pprofile .Profile (p )
2022 var joinedErr error
2123
22- vts , err := newValueTypes (p , pp .SampleType ())
24+ vts , err := newValueTypes (p , p .SampleType ())
2325 joinedErr = errors .Join (joinedErr , err )
2426 joinedErr = errors .Join (joinedErr , encoder .AddArray ("sample_type" , vts ))
2527
26- ss , err := newSamples (p , pp .Sample ())
28+ ss , err := newSamples (p , p .Sample ())
2729 joinedErr = errors .Join (joinedErr , err )
2830 joinedErr = errors .Join (joinedErr , encoder .AddArray ("sample" , ss ))
2931
30- encoder .AddInt64 ("time_nanos" , int64 (pp .Time ()))
31- encoder .AddInt64 ("duration_nanos" , int64 (pp .Duration ()))
32+ encoder .AddInt64 ("time_nanos" , int64 (p .Time ()))
33+ encoder .AddInt64 ("duration_nanos" , int64 (p .Duration ()))
3234
33- vt , err := newValueType (p , pp .PeriodType ())
35+ vt , err := newValueType (p , p .PeriodType ())
3436 joinedErr = errors .Join (joinedErr , err )
3537 joinedErr = errors .Join (joinedErr , encoder .AddObject ("period_type" , vt ))
3638
37- encoder .AddInt64 ("period" , pp .Period ())
39+ encoder .AddInt64 ("period" , p .Period ())
3840
3941 cs , err := p .getComments ()
4042 joinedErr = errors .Join (joinedErr , err )
4143 joinedErr = errors .Join (joinedErr , encoder .AddArray ("comments" , cs ))
4244
43- dst , err := p .getString (pp . DefaultSampleTypeStrindex ())
45+ dst , err := p .getString (p . DefaultSampleTypeIndex ())
4446 joinedErr = errors .Join (joinedErr , err )
4547 encoder .AddString ("default_sample_type" , dst )
4648
47- pid := pp .ProfileID ()
49+ pid := p .ProfileID ()
4850 encoder .AddString ("profile_id" , hex .EncodeToString (pid [:]))
49- encoder .AddUint32 ("dropped_attributes_count" , pp .DroppedAttributesCount ())
50- encoder .AddString ("original_payload_format" , pp .OriginalPayloadFormat ())
51- encoder .AddByteString ("original_payload" , pp .OriginalPayload ().AsRaw ())
51+ encoder .AddUint32 ("dropped_attributes_count" , p .DroppedAttributesCount ())
52+ encoder .AddString ("original_payload_format" , p .OriginalPayloadFormat ())
53+ encoder .AddByteString ("original_payload" , p .OriginalPayload ().AsRaw ())
5254
53- ats , err := newAttributes (p , pp .AttributeIndices ())
55+ ats , err := newAttributes (p , p .AttributeIndices ())
5456 joinedErr = errors .Join (joinedErr , err )
5557 joinedErr = errors .Join (joinedErr , encoder .AddArray ("attributes" , ats ))
5658
5759 return joinedErr
5860}
5961
6062func (p Profile ) getString (idx int32 ) (string , error ) {
61- pp := pprofile .Profile (p )
62- strTable := pp .StringTable ()
63+ strTable := p .Dictionary .StringTable ()
6364 if idx >= int32 (strTable .Len ()) {
6465 return "" , fmt .Errorf ("string index out of bounds: %d" , idx )
6566 }
6667 return strTable .At (int (idx )), nil
6768}
6869
6970func (p Profile ) getFunction (idx int32 ) (function , error ) {
70- pp := pprofile .Profile (p )
71- fnTable := pp .FunctionTable ()
71+ fnTable := p .Dictionary .FunctionTable ()
7272 if idx >= int32 (fnTable .Len ()) {
7373 return function {}, fmt .Errorf ("function index out of bounds: %d" , idx )
7474 }
7575 return newFunction (p , fnTable .At (int (idx )))
7676}
7777
7878func (p Profile ) getMapping (idx int32 ) (mapping , error ) {
79- pp := pprofile .Profile (p )
80- mTable := pp .MappingTable ()
79+ mTable := p .Dictionary .MappingTable ()
8180 if idx >= int32 (mTable .Len ()) {
8281 return mapping {}, fmt .Errorf ("mapping index out of bounds: %d" , idx )
8382 }
8483 return newMapping (p , mTable .At (int (idx )))
8584}
8685
8786func (p Profile ) getLink (idx int32 ) (link , error ) {
88- pp := pprofile .Profile (p )
89- lTable := pp .LinkTable ()
87+ lTable := p .Dictionary .LinkTable ()
9088 if idx >= int32 (lTable .Len ()) {
9189 return link {}, fmt .Errorf ("link index out of bounds: %d" , idx )
9290 }
9391 return link {lTable .At (int (idx ))}, nil
9492}
9593
9694func (p Profile ) getLocations (start , length int32 ) (locations , error ) {
97- pp := pprofile .Profile (p )
98- locTable := pp .LocationTable ()
95+ locTable := p .Dictionary .LocationTable ()
9996 if start >= int32 (locTable .Len ()) {
10097 return locations {}, fmt .Errorf ("location start index out of bounds: %d" , start )
10198 }
@@ -115,8 +112,7 @@ func (p Profile) getLocations(start, length int32) (locations, error) {
115112}
116113
117114func (p Profile ) getAttribute (idx int32 ) (attribute , error ) {
118- pp := pprofile .Profile (p )
119- attrTable := pp .AttributeTable ()
115+ attrTable := p .Dictionary .AttributeTable ()
120116 if idx >= int32 (attrTable .Len ()) {
121117 return attribute {}, fmt .Errorf ("attribute index out of bounds: %d" , idx )
122118 }
@@ -504,11 +500,10 @@ type comments []string
504500
505501func (p Profile ) getComments () (comments , error ) {
506502 var joinedErr error
507- pp := pprofile .Profile (p )
508- l := pp .CommentStrindices ().Len ()
503+ l := p .CommentStrindices ().Len ()
509504 cs := make (comments , 0 , l )
510505 for i := range l {
511- c , err := p .getString (pp .CommentStrindices ().At (i ))
506+ c , err := p .getString (p .CommentStrindices ().At (i ))
512507 if err != nil {
513508 joinedErr = errors .Join (joinedErr , err )
514509 }
0 commit comments