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

Method diffProcessors

modules/generator/instance.go:273–308  ·  view source on GitHub ↗

diffProcessors compares the existing processors with the desired processors and config. Must be called under a read lock.

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

Source from the content-addressed store, hash-verified

271// diffProcessors compares the existing processors with the desired processors and config.
272// Must be called under a read lock.
273func (i *instance) diffProcessors(desiredProcessors map[string]struct{}, desiredCfg ProcessorConfig) (toAdd, toRemove, toReplace []string, err error) {
274 for processorName := range desiredProcessors {
275 if _, ok := i.processors[processorName]; !ok {
276 toAdd = append(toAdd, processorName)
277 }
278 }
279 for processorName, processor := range i.processors {
280 if _, ok := desiredProcessors[processorName]; !ok {
281 toRemove = append(toRemove, processorName)
282 continue
283 }
284
285 switch p := processor.(type) {
286 case *spanmetrics.Processor:
287 if !reflect.DeepEqual(p.Cfg, desiredCfg.SpanMetrics) {
288 toReplace = append(toReplace, processorName)
289 }
290 case *servicegraphs.Processor:
291 if !reflect.DeepEqual(p.Cfg, desiredCfg.ServiceGraphs) {
292 toReplace = append(toReplace, processorName)
293 }
294 case *hostinfo.Processor:
295 if !reflect.DeepEqual(p.Cfg, desiredCfg.HostInfo) {
296 toReplace = append(toReplace, processorName)
297 }
298 default:
299 level.Error(i.logger).Log(
300 "msg", fmt.Sprintf("processor does not exist, supported processors: [%s]", strings.Join(validation.SupportedProcessors, ", ")),
301 "processorName", processorName,
302 )
303 err = fmt.Errorf("unknown processor %s", processorName)
304 return
305 }
306 }
307 return
308}
309
310// addProcessor registers the processor and adds it to the processors map. Must be called under a
311// write lock.

Callers 2

updateProcessorsMethod · 0.95

Calls 3

LogMethod · 0.65
ErrorMethod · 0.65
JoinMethod · 0.65

Tested by 1