(appender storage.Appender, timeMs int64)
| 175 | } |
| 176 | |
| 177 | func (h *histogram) collectMetrics(appender storage.Appender, timeMs int64) error { |
| 178 | h.seriesMtx.Lock() |
| 179 | defer h.seriesMtx.Unlock() |
| 180 | |
| 181 | for _, s := range h.series { |
| 182 | // If we are about to call Append for the first time on a series, |
| 183 | // we need to first insert a 0 value to allow Prometheus to start from a non-null value. |
| 184 | if s.isNew() { |
| 185 | // We set the timestamp of the init serie at the end of the previous minute, that way we ensure it ends in a |
| 186 | // different aggregation interval to avoid be downsampled. |
| 187 | endOfLastMinuteMs := getEndOfLastMinuteMs(timeMs) |
| 188 | _, err := appender.Append(0, s.countLabels, endOfLastMinuteMs, 0) |
| 189 | if err != nil && !isOutOfOrderError(err) { |
| 190 | return err |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // sum |
| 195 | _, err := appender.Append(0, s.sumLabels, timeMs, s.sum.Load()) |
| 196 | if err != nil { |
| 197 | return err |
| 198 | } |
| 199 | |
| 200 | // count |
| 201 | _, err = appender.Append(0, s.countLabels, timeMs, s.count.Load()) |
| 202 | if err != nil { |
| 203 | return err |
| 204 | } |
| 205 | |
| 206 | // bucket |
| 207 | for i := range h.bucketLabels { |
| 208 | if s.isNew() { |
| 209 | endOfLastMinuteMs := getEndOfLastMinuteMs(timeMs) |
| 210 | _, err = appender.Append(0, s.bucketLabels[i], endOfLastMinuteMs, 0) |
| 211 | if err != nil && !isOutOfOrderError(err) { |
| 212 | return err |
| 213 | } |
| 214 | } |
| 215 | ref, err := appender.Append(0, s.bucketLabels[i], timeMs, s.buckets[i].Load()) |
| 216 | if err != nil { |
| 217 | return err |
| 218 | } |
| 219 | |
| 220 | ex := s.exemplars[i].Load() |
| 221 | if ex != "" { |
| 222 | |
| 223 | lbls := []labels.Label{{ |
| 224 | Name: h.traceIDLabelName, |
| 225 | Value: ex, |
| 226 | }} |
| 227 | |
| 228 | _, err = appender.AppendExemplar(ref, s.bucketLabels[i], exemplar.Exemplar{ |
| 229 | Labels: labels.New(lbls...), |
| 230 | Value: s.exemplarValues[i].Load(), |
| 231 | Ts: timeMs, |
| 232 | }) |
| 233 | if err != nil { |
| 234 | return err |
nothing calls this directly
no test coverage detected