Skip to content

Commit 13cbb35

Browse files
authored
fix: Add profile_name label to Speedscope profile ingestion (#4588)
This label is important to prevent all speedscope profiles from the same ingestion upload being deduped during compaction
1 parent f2aa2fb commit 13cbb35

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pkg/og/convert/speedscope/parser.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ func parseOne(prof *profile, putInput storage.PutInput, frames []frame, multi bo
7070
putInput.LabelSet = prof.Unit.chooseKey(putInput.LabelSet)
7171
}
7272

73+
// This label is important to prevent all speedscope profiles
74+
// from the same ingestion upload being deduped during compaction.
75+
// Currently, all profiles are associated with the same timestamp
76+
// from `putInput`. Since profiles are deduped over label set + timestamp,
77+
// this label prevents unintended downstream deduping.
78+
putInput.LabelSet.Add("profile_name", prof.Name)
79+
7380
// TODO(petethepig): We need a way to tell if it's a default or a value set by user
7481
// See https://github.com/pyroscope-io/pyroscope/issues/1598
7582
if putInput.SampleRate == 100 {

pkg/og/convert/speedscope/speedscope_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var _ = Describe("Speedscope", func() {
4040
input := ingester.actual[0]
4141

4242
Expect(input.Units).To(Equal(metadata.SamplesUnits))
43-
Expect(input.LabelSet.Normalized()).To(Equal("foo{}"))
43+
Expect(input.LabelSet.Normalized()).To(Equal("foo{profile_name=simple.txt}"))
4444
expectedResult := `a;b 500
4545
a;b;c 500
4646
a;b;d 400
@@ -67,12 +67,18 @@ a;b;d 400
6767

6868
input := ingester.actual[0]
6969
Expect(input.Units).To(Equal(metadata.SamplesUnits))
70-
Expect(input.LabelSet.Normalized()).To(Equal("foo.seconds{x=y}"))
70+
Expect(input.LabelSet.Normalized()).To(Equal("foo.seconds{profile_name=one,x=y}"))
7171
expectedResult := `a;b 500
7272
a;b;c 500
7373
a;b;d 400
7474
`
7575
Expect(input.Val.String()).To(Equal(expectedResult))
7676
Expect(input.SampleRate).To(Equal(uint32(100)))
77+
78+
input2 := ingester.actual[1]
79+
Expect(input2.Units).To(Equal(metadata.SamplesUnits))
80+
Expect(input2.LabelSet.Normalized()).To(Equal("foo.seconds{profile_name=two,x=y}"))
81+
Expect(input2.Val.String()).To(Equal(expectedResult))
82+
Expect(input2.SampleRate).To(Equal(uint32(100)))
7783
})
7884
})

0 commit comments

Comments
 (0)