From cdfa63d5ca769406a18204f6b385c88e400c6f3f Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Thu, 7 Apr 2022 09:51:34 +0200 Subject: [PATCH] Filter out unrequested scopes when fetching data from archive --- metricdata/metricdata.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/metricdata/metricdata.go b/metricdata/metricdata.go index 926695e..9d47664 100644 --- a/metricdata/metricdata.go +++ b/metricdata/metricdata.go @@ -108,11 +108,18 @@ func LoadData(job *schema.Job, metrics []string, scopes []schema.MetricScope, ct } // Avoid sending unrequested data to the client: - if metrics != nil { + if metrics != nil || scopes != nil { + if metrics == nil { + metrics = make([]string, 0, len(jd)) + for k := range jd { + metrics = append(metrics, k) + } + } + res := schema.JobData{} for _, metric := range metrics { if perscope, ok := jd[metric]; ok { - if len(scopes) > 1 { + if len(perscope) > 1 { subset := make(map[schema.MetricScope]*schema.JobMetric) for _, scope := range scopes { if jm, ok := perscope[scope]; ok {