Skip to content

Commit ae6c110

Browse files
authored
fix: pprof merge profiles ignoring sample type stub (#3198)
1 parent aca54af commit ae6c110

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pkg/pprof/merge.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,12 @@ func equalValueType(st1, st2 *profilev1.ValueType) bool {
218218

219219
func RewriteStrings(p *profilev1.Profile, n []uint32) {
220220
for _, t := range p.SampleType {
221-
t.Unit = int64(n[t.Unit])
222-
t.Type = int64(n[t.Type])
221+
if t.Unit != 0 {
222+
t.Unit = int64(n[t.Unit])
223+
}
224+
if t.Type != 0 {
225+
t.Type = int64(n[t.Type])
226+
}
223227
}
224228
for _, s := range p.Sample {
225229
for _, l := range s.Label {
@@ -238,8 +242,12 @@ func RewriteStrings(p *profilev1.Profile, n []uint32) {
238242
}
239243
p.DropFrames = int64(n[p.DropFrames])
240244
p.KeepFrames = int64(n[p.KeepFrames])
241-
p.PeriodType.Type = int64(n[p.PeriodType.Type])
242-
p.PeriodType.Unit = int64(n[p.PeriodType.Unit])
245+
if p.PeriodType.Type != 0 {
246+
p.PeriodType.Type = int64(n[p.PeriodType.Type])
247+
}
248+
if p.PeriodType.Unit != 0 {
249+
p.PeriodType.Unit = int64(n[p.PeriodType.Unit])
250+
}
243251
for i, x := range p.Comment {
244252
p.Comment[i] = int64(n[x])
245253
}

0 commit comments

Comments
 (0)