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

Method updateSubprocessors

modules/generator/instance.go:156–201  ·  view source on GitHub ↗

Look at the processors defined and see if any are actually span-metrics subprocessors If they are, set the appropriate flags in the spanmetrics struct

(desiredProcessors map[string]struct{}, desiredCfg ProcessorConfig)

Source from the content-addressed store, hash-verified

154// Look at the processors defined and see if any are actually span-metrics subprocessors
155// If they are, set the appropriate flags in the spanmetrics struct
156func (i *instance) updateSubprocessors(desiredProcessors map[string]struct{}, desiredCfg ProcessorConfig) (map[string]struct{}, ProcessorConfig) {
157 desiredProcessorsFound := false
158 for d := range desiredProcessors {
159 if (d == processor.SpanMetricsName) || (spanmetrics.ParseSubprocessor(d)) {
160 desiredProcessorsFound = true
161 }
162 }
163
164 if !desiredProcessorsFound {
165 return desiredProcessors, desiredCfg
166 }
167
168 _, allOk := desiredProcessors[processor.SpanMetricsName]
169 _, countOk := desiredProcessors[spanmetrics.Count.String()]
170 _, latencyOk := desiredProcessors[spanmetrics.Latency.String()]
171 _, sizeOk := desiredProcessors[spanmetrics.Size.String()]
172
173 // Copy the map before modifying it. This map can be shared by multiple instances and is not safe to write to.
174 newDesiredProcessors := map[string]struct{}{}
175 maps.Copy(newDesiredProcessors, desiredProcessors)
176
177 if !allOk {
178 newDesiredProcessors[processor.SpanMetricsName] = struct{}{}
179 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Count] = false
180 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Latency] = false
181 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Size] = false
182 desiredCfg.SpanMetrics.HistogramBuckets = nil
183
184 if countOk {
185 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Count] = true
186 }
187 if latencyOk {
188 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Latency] = true
189 desiredCfg.SpanMetrics.HistogramBuckets = prometheus.ExponentialBuckets(0.002, 2, 14)
190 }
191 if sizeOk {
192 desiredCfg.SpanMetrics.Subprocessors[spanmetrics.Size] = true
193 }
194 }
195
196 delete(newDesiredProcessors, spanmetrics.Latency.String())
197 delete(newDesiredProcessors, spanmetrics.Count.String())
198 delete(newDesiredProcessors, spanmetrics.Size.String())
199
200 return newDesiredProcessors, desiredCfg
201}
202
203func (i *instance) updateProcessors() error {
204 desiredProcessors := i.filterSupportedProcessors(i.overrides.MetricsGeneratorProcessors(i.instanceID))

Callers 1

updateProcessorsMethod · 0.95

Calls 2

ParseSubprocessorFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected