Skip to content

Commit

Permalink
[exporter/awsemf] Enhance unit conversion (amazon-contributing#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrara authored Oct 24, 2024
1 parent 0c70760 commit f0b80d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion exporter/awsemfexporter/grouped_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func translateUnit(metric pmetric.Metric, descriptor map[string]MetricDescriptor
}
}
switch unit {
case "1":
unit = ""
case "ns":
// CloudWatch doesn't support Nanoseconds
unit = ""
case "ms":
unit = "Milliseconds"
case "s":
Expand All @@ -202,7 +207,7 @@ func translateUnit(metric pmetric.Metric, descriptor map[string]MetricDescriptor
unit = "Microseconds"
case "By":
unit = "Bytes"
case "Bi":
case "bit":
unit = "Bits"
}
return unit
Expand Down
4 changes: 3 additions & 1 deletion exporter/awsemfexporter/grouped_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,12 @@ func TestTranslateUnit(t *testing.T) {
translateUnitCases := map[string]string{
"Count": "Count",
"ms": "Milliseconds",
"ns": "",
"1": "",
"s": "Seconds",
"us": "Microseconds",
"By": "Bytes",
"Bi": "Bits",
"bit": "Bits",
}
for input, output := range translateUnitCases {
t.Run(input, func(_ *testing.T) {
Expand Down

0 comments on commit f0b80d5

Please sign in to comment.