Skip to content

Commit 5c90a06

Browse files
authored
fix: preserve original timestamps in exemplars during aggregation (#4637)
1 parent eb847bd commit 5c90a06

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

pkg/model/time_series.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ func (a *sumTimeSeriesAggregator) GetAndReset() *typesv1.Point {
117117
var exemplars []*typesv1.Exemplar
118118
if len(a.exemplars) > 0 {
119119
exemplars = selectTopNExemplarsProto(a.exemplars, a.maxExemplarsPerPoint)
120-
for _, ex := range exemplars {
121-
ex.Timestamp = tsCopy
122-
}
123120
}
124121

125122
a.ts = -1
@@ -167,9 +164,6 @@ func (a *avgTimeSeriesAggregator) GetAndReset() *typesv1.Point {
167164
var exemplars []*typesv1.Exemplar
168165
if len(a.exemplars) > 0 {
169166
exemplars = selectTopNExemplarsProto(a.exemplars, a.maxExemplarsPerPoint)
170-
for _, ex := range exemplars {
171-
ex.Timestamp = tsCopy
172-
}
173167
}
174168

175169
a.ts = -1

pkg/model/time_series_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ func Test_RangeSeriesWithExemplars(t *testing.T) {
169169
out []*typesv1.Series
170170
}{
171171
{
172-
name: "exemplar tracking keeps highest value",
172+
name: "exemplar timestamps preserved during aggregation",
173173
series: []*typesv1.Series{{
174174
Labels: []*typesv1.LabelPair{{Name: "service_name", Value: "api"}},
175175
Points: []*typesv1.Point{
176-
{Timestamp: 1000, Value: 100.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-1", Value: 100, Timestamp: 1000}}},
177-
{Timestamp: 1000, Value: 300.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-2", Value: 300, Timestamp: 1000}}},
178-
{Timestamp: 2000, Value: 200.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-3", Value: 200, Timestamp: 2000}}},
176+
{Timestamp: 947, Value: 100.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-1", Value: 100, Timestamp: 947}}},
177+
{Timestamp: 987, Value: 300.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-2", Value: 300, Timestamp: 987}}},
178+
{Timestamp: 1847, Value: 200.0, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-3", Value: 200, Timestamp: 1847}}},
179179
},
180180
}},
181181
start: 1000,
@@ -185,8 +185,8 @@ func Test_RangeSeriesWithExemplars(t *testing.T) {
185185
out: []*typesv1.Series{{
186186
Labels: []*typesv1.LabelPair{{Name: "service_name", Value: "api"}},
187187
Points: []*typesv1.Point{
188-
{Timestamp: 1000, Value: 400.0, Annotations: []*typesv1.ProfileAnnotation{}, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-2", Value: 300, Timestamp: 1000}}},
189-
{Timestamp: 2000, Value: 200.0, Annotations: []*typesv1.ProfileAnnotation{}, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-3", Value: 200, Timestamp: 2000}}},
188+
{Timestamp: 1000, Value: 400.0, Annotations: []*typesv1.ProfileAnnotation{}, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-2", Value: 300, Timestamp: 987}}},
189+
{Timestamp: 2000, Value: 200.0, Annotations: []*typesv1.ProfileAnnotation{}, Exemplars: []*typesv1.Exemplar{{ProfileId: "prof-3", Value: 200, Timestamp: 1847}}},
190190
},
191191
}},
192192
},

0 commit comments

Comments
 (0)