(lbls labels.Labels, value float64, traceID string, multiplier float64)
| 112 | } |
| 113 | |
| 114 | func (h *histogram) newSeries(lbls labels.Labels, value float64, traceID string, multiplier float64) *histogramSeries { |
| 115 | newSeries := &histogramSeries{ |
| 116 | count: atomic.NewFloat64(0), |
| 117 | sum: atomic.NewFloat64(0), |
| 118 | buckets: make([]*atomic.Float64, 0, len(h.buckets)), |
| 119 | exemplars: make([]*atomic.String, 0, len(h.buckets)), |
| 120 | exemplarValues: make([]*atomic.Float64, 0, len(h.buckets)), |
| 121 | lastUpdated: atomic.NewInt64(0), |
| 122 | firstSeries: atomic.NewBool(true), |
| 123 | } |
| 124 | for i := 0; i < len(h.buckets); i++ { |
| 125 | newSeries.buckets = append(newSeries.buckets, atomic.NewFloat64(0)) |
| 126 | newSeries.exemplars = append(newSeries.exemplars, atomic.NewString("")) |
| 127 | newSeries.exemplarValues = append(newSeries.exemplarValues, atomic.NewFloat64(0)) |
| 128 | } |
| 129 | |
| 130 | // Precompute all labels for all sub-metrics upfront |
| 131 | |
| 132 | // Create and populate label builder |
| 133 | lb := newSeriesLabelsBuilder(lbls, h.externalLabels) |
| 134 | |
| 135 | // _count |
| 136 | lb.Set(labels.MetricName, h.nameCount) |
| 137 | newSeries.countLabels = lb.Labels() |
| 138 | |
| 139 | // _sum |
| 140 | lb.Set(labels.MetricName, h.nameSum) |
| 141 | newSeries.sumLabels = lb.Labels() |
| 142 | |
| 143 | // _bucket |
| 144 | lb.Set(labels.MetricName, h.nameBucket) |
| 145 | for _, b := range h.bucketLabels { |
| 146 | lb.Set(labels.BucketLabel, b) |
| 147 | newSeries.bucketLabels = append(newSeries.bucketLabels, lb.Labels()) |
| 148 | } |
| 149 | |
| 150 | h.updateSeries(lbls.Hash(), newSeries, value, traceID, multiplier) |
| 151 | |
| 152 | return newSeries |
| 153 | } |
| 154 | |
| 155 | func (h *histogram) updateSeries(hash uint64, s *histogramSeries, value float64, traceID string, multiplier float64) { |
| 156 | s.count.Add(1 * multiplier) |
no test coverage detected