MCPcopy Index your code
hub / github.com/netdata/netdata / resolveAlgorithm

Function resolveAlgorithm

src/go/plugin/framework/chartengine/compiler.go:284–308  ·  view source on GitHub ↗
(raw string, metricKinds map[string]bool)

Source from the content-addressed store, hash-verified

282}
283
284func resolveAlgorithm(raw string, metricKinds map[string]bool) (program.Algorithm, error) {
285 normalized := strings.TrimSpace(raw)
286 if normalized != "" {
287 switch normalized {
288 case string(program.AlgorithmAbsolute):
289 return program.AlgorithmAbsolute, nil
290 case string(program.AlgorithmIncremental):
291 return program.AlgorithmIncremental, nil
292 default:
293 return "", fmt.Errorf("invalid algorithm %q", raw)
294 }
295 }
296
297 // Inference baseline:
298 // - counter-like selectors => incremental
299 // - gauge-like selectors => absolute
300 // - mixed inferred kinds must be explicit.
301 if metricKinds["counter_like"] && metricKinds["gauge_like"] {
302 return "", fmt.Errorf("algorithm inference is ambiguous for mixed metric kinds; set algorithm explicitly")
303 }
304 if metricKinds["counter_like"] {
305 return program.AlgorithmIncremental, nil
306 }
307 return program.AlgorithmAbsolute, nil
308}
309
310func resolveChartType(raw string) (program.ChartType, error) {
311 normalized := strings.TrimSpace(raw)

Callers 1

compileChartMethod · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…