Skip to content

Commit

Permalink
Remove internal entity fields for awsemfexporter (#271)
Browse files Browse the repository at this point in the history
* Remove internal entity fields for emf_exporter

* Add test for internal entity field skipping
  • Loading branch information
duhminick authored Jan 16, 2025
1 parent d03e737 commit 07637c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions exporter/awsemfexporter/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"math"
"strconv"
"strings"
"time"

"go.opentelemetry.io/collector/pdata/pcommon"
Expand All @@ -18,6 +19,8 @@ import (
)

const (
AWSEntityPrefix = "com.amazonaws.cloudwatch.entity.internal."

summaryCountSuffix = "_count"
summarySumSuffix = "_sum"
)
Expand Down Expand Up @@ -531,6 +534,11 @@ func (dps summaryDataPointSlice) IsStaleNaNInf(i int) (bool, pcommon.Map) {
func createLabels(attributes pcommon.Map) map[string]string {
labels := make(map[string]string, attributes.Len()+1)
attributes.Range(func(k string, v pcommon.Value) bool {
// we don't want to export entity related attributes as dimensions, so we skip these
if strings.HasPrefix(k, AWSEntityPrefix) {
return true
}

labels[k] = v.AsString()
return true
})
Expand Down
1 change: 1 addition & 0 deletions exporter/awsemfexporter/datapoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,7 @@ func TestCreateLabels(t *testing.T) {
"a": "A",
"b": "B",
"c": "C",
"com.amazonaws.cloudwatch.entity.internal.A": "A",
}))

labels := createLabels(labelsMap)
Expand Down

0 comments on commit 07637c7

Please sign in to comment.