Add exemplars for native histograms

This commit is contained in:
Shivanth 2024-11-17 20:29:39 +01:00
parent 291b0b0c42
commit 8b1189b8a7
1 changed files with 4 additions and 0 deletions

View File

@ -186,6 +186,10 @@ func (m *withExemplarsMetric) Write(pb *dto.Metric) error {
case pb.Counter != nil:
pb.Counter.Exemplar = m.exemplars[len(m.exemplars)-1]
case pb.Histogram != nil:
if *pb.Histogram.Schema > math.MinInt32 {
exemplars := m.exemplars
pb.Histogram.Exemplars = append(pb.Histogram.Exemplars, m.exemplars...)
}
for _, e := range m.exemplars {
// pb.Histogram.Bucket are sorted by UpperBound.
i := sort.Search(len(pb.Histogram.Bucket), func(i int) bool {