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

Method newSeries

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

Source from the content-addressed store, hash-verified

131}
132
133func (h *nativeHistogram) newSeries(lbls labels.Labels, value float64, traceID string, multiplier float64) *nativeHistogramSeries {
134 // Configure histogram based on mode
135 //
136 // Native-only mode sets buckets to nil, and uses the histogram.Exemplars slice as the native exemplar format.
137 // Hybrid mode uses classic buckets and bucket.Exemplar format for compatibility.
138
139 var buckets []float64
140
141 // The native histogram only uses the static buckets when the classic histograms are enabled.
142 hasClassic := hasClassicHistograms(h.histogramOverride)
143 if hasClassic {
144 // Hybrid "both" mode: include classic buckets for compatibility
145 buckets = h.buckets
146 }
147
148 hsh, bucketFactor, maxBucketNum, minResetDur := h.hashOverrides()
149
150 // Configure native histogram options based on mode
151 nativeOpts := prometheus.HistogramOpts{
152 Name: h.name(),
153 Help: "Native histogram for metric " + h.name(),
154 Buckets: buckets, // nil for pure native, h.buckets for hybrid
155 // Native histogram parameters
156 NativeHistogramBucketFactor: bucketFactor,
157 NativeHistogramMaxBucketNumber: maxBucketNum,
158 NativeHistogramMinResetDuration: minResetDur,
159 }
160
161 if hasClassic {
162 // Hybrid mode: let Prometheus decide defaults for compatibility
163 nativeOpts.NativeHistogramMaxExemplars = -1 // Use default
164 }
165
166 newSeries := &nativeHistogramSeries{
167 promHistogram: prometheus.NewHistogram(nativeOpts),
168 lastUpdated: 0,
169 firstSeries: atomic.NewBool(true),
170 overridesHash: hsh,
171 }
172
173 h.updateSeries(lbls.Hash(), newSeries, value, traceID, multiplier)
174
175 lb := newSeriesLabelsBuilder(lbls, h.externalLabels)
176
177 lb.Set(labels.MetricName, h.metricName)
178
179 newSeries.labels = lb.Labels()
180 newSeries.lb = lb
181
182 // _count
183 lb.Set(labels.MetricName, h.nameCount)
184 newSeries.countLabels = lb.Labels()
185
186 // _sum
187 lb.Set(labels.MetricName, h.nameSum)
188 newSeries.sumLabels = lb.Labels()
189
190 return newSeries

Callers 1

ObserveWithExemplarMethod · 0.95

Calls 8

hashOverridesMethod · 0.95
nameMethod · 0.95
updateSeriesMethod · 0.95
hasClassicHistogramsFunction · 0.85
newSeriesLabelsBuilderFunction · 0.85
HashMethod · 0.80
NewHistogramMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected