(value float64)
| 334 | } |
| 335 | |
| 336 | func (p *promTextParser) addHistogram(value float64) { |
| 337 | hash := p.currSeries.Hash() |
| 338 | |
| 339 | p.currSeries, _, _ = removeLabel(p.currSeries, labels.MetricName) |
| 340 | |
| 341 | h, ok := p.histograms[hash] |
| 342 | if !ok { |
| 343 | if v := len(p.currMF.metrics); v == cap(p.currMF.metrics) { |
| 344 | h = &Histogram{} |
| 345 | p.currMF.metrics = append(p.currMF.metrics, Metric{ |
| 346 | labels: copyLabels(p.currSeries), |
| 347 | histogram: h, |
| 348 | }) |
| 349 | } else { |
| 350 | p.currMF.metrics = p.currMF.metrics[:v+1] |
| 351 | if p.currMF.metrics[v].histogram == nil { |
| 352 | p.currMF.metrics[v].histogram = &Histogram{} |
| 353 | } |
| 354 | p.currMF.metrics[v].histogram.sum = 0 |
| 355 | p.currMF.metrics[v].histogram.count = 0 |
| 356 | p.currMF.metrics[v].histogram.buckets = p.currMF.metrics[v].histogram.buckets[:0] |
| 357 | p.currMF.metrics[v].labels = p.currMF.metrics[v].labels[:0] |
| 358 | p.currMF.metrics[v].labels = append(p.currMF.metrics[v].labels, p.currSeries...) |
| 359 | h = p.currMF.metrics[v].histogram |
| 360 | } |
| 361 | |
| 362 | p.histograms[hash] = h |
| 363 | } |
| 364 | |
| 365 | switch { |
| 366 | case p.isBucket: |
| 367 | h.buckets = append(h.buckets, Bucket{upperBound: p.currBucket, cumulativeCount: value}) |
| 368 | case p.isSum: |
| 369 | h.sum = value |
| 370 | case p.isCount: |
| 371 | h.count = value |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | func (p *promTextParser) reset() { |
| 376 | p.currMF = nil |
no test coverage detected