Skip to content

Commit

Permalink
aws/containerinsight: convert uint types to int instead of float (#5037)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
  • Loading branch information
Aneurysm9 authored Aug 31, 2021
1 parent 5bc5b75 commit db1e2b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions internal/aws/containerinsight/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions internal/aws/containerinsight/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit db1e2b2

Please sign in to comment.