MCPcopy
hub / github.com/grafana/tempo / newSeries

Method newSeries

modules/generator/registry/histogram.go:114–153  ·  view source on GitHub ↗
(lbls labels.Labels, value float64, traceID string, multiplier float64)

Source from the content-addressed store, hash-verified

112}
113
114func (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
155func (h *histogram) updateSeries(hash uint64, s *histogramSeries, value float64, traceID string, multiplier float64) {
156 s.count.Add(1 * multiplier)

Callers 1

ObserveWithExemplarMethod · 0.95

Calls 4

updateSeriesMethod · 0.95
newSeriesLabelsBuilderFunction · 0.85
HashMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected