fix: forward resample algorithm to metric store for running jobs

Only archived job data and internal-store node-list data honoured the
selected resample algorithm. For running jobs the algorithm was dropped:
MetricDataRepository.LoadData had no such parameter, so the memory store
fell back to an empty string, which cc-lib's GetResampler maps to LTTB.
The external store client was worse - its APIQueryRequest had no
ResampleAlgo field at all, and LoadNodeListData accepted the parameter
without using it.

Add resampleAlgo to the LoadData interface (mirroring LoadNodeListData),
forward it from metricdispatch, and set it on both stores' requests. The
field is tagged omitempty, so the wire format is unchanged when empty -
verify the deployed cc-metric-store accepts it before relying on it there.

The REST job endpoints pass a non-zero resolution and therefore do
resample, so they now request the configured default instead of an empty
string. Add config.ResampleAlgo() for that, since "" is not a neutral
value at this layer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-27 12:17:03 +02:00
co-authored by Claude Opus 5
parent d40390061d
commit a5c1fdf21f
8 changed files with 59 additions and 36 deletions
+15
View File
@@ -193,6 +193,21 @@ func initResampler() {
// DefaultResamplePolicy is used when no resample policy is configured.
const DefaultResamplePolicy = "medium"
// DefaultResampleAlgo is used when neither the user nor the config selects a
// resample algorithm. "average" performs RRDTool-style interval averaging,
// which keeps each plotted point a true mean of its interval.
const DefaultResampleAlgo = "average"
// ResampleAlgo returns the configured default resample algorithm, falling back
// to DefaultResampleAlgo. Note that an empty string would select LTTB in
// cc-lib's resampler, so callers must not pass "" when they mean "the default".
func ResampleAlgo() string {
if Keys.EnableResampling != nil && Keys.EnableResampling.DefaultAlgo != "" {
return Keys.EnableResampling.DefaultAlgo
}
return DefaultResampleAlgo
}
// TargetPointsForPolicy returns the target number of data points for a resample
// policy. This is the single source of truth: it feeds both the requested
// resolution (via metricdispatch.ComputeResolution) and the resampler's