(raw string, metricKinds map[string]bool)
| 282 | } |
| 283 | |
| 284 | func 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 | |
| 310 | func resolveChartType(raw string) (program.ChartType, error) { |
| 311 | normalized := strings.TrimSpace(raw) |
no test coverage detected
searching dependent graphs…