Skip to content

Commit

Permalink
just add
Browse files Browse the repository at this point in the history
  • Loading branch information
musa-asad committed Feb 6, 2025
1 parent 1ee3543 commit 54491ce
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions exporter/awsemfexporter/internal/entity/entityattributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,22 @@ var attributeEntityToFieldMap = map[string]string{
AttributeEntityServiceNameSource: AWSServiceNameSource,
}

// AddEntity populates resource attributes with entity fields
func AddEntity(am pcommon.Map) {
// Check if all resource attributes for entity exist, otherwise don't add entity
for internalAttr := range attributeEntityToFieldMap {
if _, found := am.Get(internalAttr); !found {
return
}
}

if _, found := am.Get(AttributeEntityK8sClusterName); !found {
return
}

// Populate resource attributes with entity fields
for internalAttr, entityField := range attributeEntityToFieldMap {
val, _ := am.Get(internalAttr)
val.CopyTo(am.PutEmpty(entityField))
val, ok := am.Get(internalAttr)
if ok {
val.CopyTo(am.PutEmpty(entityField))
}
}

val, _ := am.Get(AttributeEntityK8sClusterName)
switch val.Str() {
case AttributeEntityEKSPlatform:
val.CopyTo(am.PutEmpty(EksCluster))
case AttributeEntityK8sPlatform:
val.CopyTo(am.PutEmpty(K8sCluster))
val, ok := am.Get(AttributeEntityK8sClusterName)
if ok {
switch val.Str() {
case AttributeEntityEKSPlatform:
val.CopyTo(am.PutEmpty(EksCluster))
case AttributeEntityK8sPlatform:
val.CopyTo(am.PutEmpty(K8sCluster))
}
}
}

0 comments on commit 54491ce

Please sign in to comment.