From 66fe5113aece5329c5a931b834949a34ac816ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20=C3=87=C4=B1dam?= Date: Wed, 31 Jan 2024 14:31:13 +0300 Subject: [PATCH] fix metric counter type --- services/publisher/metrics.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/publisher/metrics.go b/services/publisher/metrics.go index 797b15a7..6854e69e 100644 --- a/services/publisher/metrics.go +++ b/services/publisher/metrics.go @@ -27,7 +27,7 @@ type metricsBucket struct { } type metricsData struct { - Counters []uint32 + Counters []float64 Details string } @@ -104,7 +104,7 @@ func (ama *AgentMetricsAggregator) AddAgentMetrics(ms *protocol.AgentMetricList) bucket := ama.findBucket(m.AgentId, chainID, t) bucket.MetricsData[m.Name] = metricsData{ - Counters: append(bucket.MetricsData[m.Name].Counters, uint32(m.Value)), + Counters: append(bucket.MetricsData[m.Name].Counters, m.Value), Details: m.Details, } } @@ -193,16 +193,16 @@ func (allMetrics allAgentMetrics) PrepareMetrics() { } } -func avgMetricArray(data []uint32) float64 { +func avgMetricArray(data []float64) float64 { sum := decimal.NewFromInt(0) for _, dataPoint := range data { - sum = sum.Add(decimal.NewFromInt32(int32(dataPoint))) + sum = sum.Add(decimal.NewFromFloat(dataPoint)) } f, _ := sum.Div(decimal.NewFromInt32(int32(len(data)))).Round(2).Float64() return f } -func maxDataPoint(data []uint32) float64 { +func maxDataPoint(data []float64) float64 { var max float64 for _, dataPoint := range data { if float64(dataPoint) > max { @@ -212,7 +212,7 @@ func maxDataPoint(data []uint32) float64 { return max } -func calcP95(data []uint32) float64 { +func calcP95(data []float64) float64 { switch len(data) { case 0: return 0 @@ -228,7 +228,7 @@ func calcP95(data []uint32) float64 { return float64(data[k95-1]) } -func sumNums(data []uint32) (n float64) { +func sumNums(data []float64) (n float64) { for _, d := range data { n += float64(d) }