From 82baf5d38438882bd933014bef82b9e562d119d9 Mon Sep 17 00:00:00 2001 From: Christoph Kluge Date: Tue, 1 Oct 2024 12:48:32 +0200 Subject: [PATCH] fix deepCopy of statisticsSeries for archived jobs --- internal/metricdata/utils.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/metricdata/utils.go b/internal/metricdata/utils.go index f480e40..dcdaaaa 100644 --- a/internal/metricdata/utils.go +++ b/internal/metricdata/utils.go @@ -72,13 +72,21 @@ func DeepCopy(jd_temp schema.JobData) schema.JobData { jd[k][k_].Unit.Base = v_.Unit.Base jd[k][k_].Unit.Prefix = v_.Unit.Prefix if v_.StatisticsSeries != nil { + // Init Slices jd[k][k_].StatisticsSeries = new(schema.StatsSeries) + jd[k][k_].StatisticsSeries.Max = make([]schema.Float, len(v_.StatisticsSeries.Max)) + jd[k][k_].StatisticsSeries.Min = make([]schema.Float, len(v_.StatisticsSeries.Min)) + jd[k][k_].StatisticsSeries.Median = make([]schema.Float, len(v_.StatisticsSeries.Median)) + jd[k][k_].StatisticsSeries.Mean = make([]schema.Float, len(v_.StatisticsSeries.Mean)) + // Copy Data copy(jd[k][k_].StatisticsSeries.Max, v_.StatisticsSeries.Max) copy(jd[k][k_].StatisticsSeries.Min, v_.StatisticsSeries.Min) copy(jd[k][k_].StatisticsSeries.Median, v_.StatisticsSeries.Median) copy(jd[k][k_].StatisticsSeries.Mean, v_.StatisticsSeries.Mean) + // Handle Percentiles for k__, v__ := range v_.StatisticsSeries.Percentiles { - jd[k][k_].StatisticsSeries.Percentiles[k__] = v__ + jd[k][k_].StatisticsSeries.Percentiles[k__] = make([]schema.Float, len(v__)) + copy(jd[k][k_].StatisticsSeries.Percentiles[k__], v__) } } else { jd[k][k_].StatisticsSeries = v_.StatisticsSeries