From db1e2b2c6e50bf5e5dc10f06ba671bc0f57ef579 Mon Sep 17 00:00:00 2001 From: Anthony Mirabella Date: Tue, 31 Aug 2021 18:09:12 -0400 Subject: [PATCH] aws/containerinsight: convert uint types to int instead of float (#5037) Signed-off-by: Anthony J Mirabella --- internal/aws/containerinsight/utils.go | 6 +++--- internal/aws/containerinsight/utils_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/aws/containerinsight/utils.go b/internal/aws/containerinsight/utils.go index d912f49ccd21..2ef9d5565c09 100644 --- a/internal/aws/containerinsight/utils.go +++ b/internal/aws/containerinsight/utils.go @@ -196,11 +196,11 @@ func ConvertToOTLPMetrics(fields map[string]interface{}, tags map[string]string, case int64: intGauge(ilms.AppendEmpty(), key, unit, t, timestamp) case uint: - doubleGauge(ilms.AppendEmpty(), key, unit, float64(t), timestamp) + intGauge(ilms.AppendEmpty(), key, unit, int64(t), timestamp) case uint32: - doubleGauge(ilms.AppendEmpty(), key, unit, float64(t), timestamp) + intGauge(ilms.AppendEmpty(), key, unit, int64(t), timestamp) case uint64: - doubleGauge(ilms.AppendEmpty(), key, unit, float64(t), timestamp) + intGauge(ilms.AppendEmpty(), key, unit, int64(t), timestamp) case float32: doubleGauge(ilms.AppendEmpty(), key, unit, float64(t), timestamp) case float64: diff --git a/internal/aws/containerinsight/utils_test.go b/internal/aws/containerinsight/utils_test.go index 5c9e1340c677..47c8403fa5a6 100644 --- a/internal/aws/containerinsight/utils_test.go +++ b/internal/aws/containerinsight/utils_test.go @@ -115,6 +115,12 @@ func convertToInt64(value interface{}) int64 { return int64(t) case int64: return t + case uint: + return int64(t) + case uint32: + return int64(t) + case uint64: + return int64(t) default: valueType := fmt.Sprintf("%T", value) log.Printf("Detected unexpected type: %v", valueType) @@ -124,12 +130,6 @@ func convertToInt64(value interface{}) int64 { func convertToFloat64(value interface{}) float64 { switch t := value.(type) { - case uint: - return float64(t) - case uint32: - return float64(t) - case uint64: - return float64(t) case float32: return float64(t) case float64: