diff --git a/plugins/processors/awsapplicationsignals/common/types.go b/plugins/processors/awsapplicationsignals/common/types.go index 86615c1f2d..0abb6b2adf 100644 --- a/plugins/processors/awsapplicationsignals/common/types.go +++ b/plugins/processors/awsapplicationsignals/common/types.go @@ -20,7 +20,7 @@ const ( AttributeEC2AutoScalingGroupName = "EC2.AutoScalingGroupName" AttributeEC2InstanceId = "EC2.InstanceId" AttributePlatformType = "PlatformType" - AttributeSDK = "SDK" + AttributeSDK = "Telemetry.SDK" ) const ( diff --git a/plugins/processors/awsapplicationsignals/internal/normalizer/attributesnormalizer_test.go b/plugins/processors/awsapplicationsignals/internal/normalizer/attributesnormalizer_test.go index c96fce4558..734af3e798 100644 --- a/plugins/processors/awsapplicationsignals/internal/normalizer/attributesnormalizer_test.go +++ b/plugins/processors/awsapplicationsignals/internal/normalizer/attributesnormalizer_test.go @@ -190,7 +190,7 @@ func Test_attributesNormalizer_appendNewAttributes(t *testing.T) { } n.appendNewAttributes(tt.attributes, tt.resourceAttributes, tt.isTrace) - if value, ok := tt.attributes.Get("SDK"); !ok { + if value, ok := tt.attributes.Get("Telemetry.SDK"); !ok { if !tt.isTrace { t.Errorf("attribute is not found.") } diff --git a/plugins/processors/awsapplicationsignals/internal/resolver/attributesresolver.go b/plugins/processors/awsapplicationsignals/internal/resolver/attributesresolver.go index bbe94ea921..e93e090cab 100644 --- a/plugins/processors/awsapplicationsignals/internal/resolver/attributesresolver.go +++ b/plugins/processors/awsapplicationsignals/internal/resolver/attributesresolver.go @@ -29,14 +29,12 @@ const ( ) var GenericInheritedAttributes = map[string]string{ - attr.AWSHostedInEnvironment: attr.AWSLocalEnvironment, semconv1.AttributeDeploymentEnvironment: attr.AWSLocalEnvironment, attr.ResourceDetectionHostName: attr.ResourceDetectionHostName, } // DefaultInheritedAttributes is an allow-list that also renames attributes from the resource detection processor var DefaultInheritedAttributes = map[string]string{ - attr.AWSHostedInEnvironment: attr.AWSLocalEnvironment, semconv1.AttributeDeploymentEnvironment: attr.AWSLocalEnvironment, attr.ResourceDetectionASG: common.AttributeEC2AutoScalingGroupName, attr.ResourceDetectionHostId: common.AttributeEC2InstanceId, @@ -110,18 +108,22 @@ func newResourceAttributesResolver(defaultEnvPrefix, platformType string, attrib func (h *resourceAttributesResolver) Process(attributes, resourceAttributes pcommon.Map) error { for attrKey, mappingKey := range h.attributeMap { if val, ok := resourceAttributes.Get(attrKey); ok { - attributes.PutStr(mappingKey, val.AsString()) + attributes.PutStr(mappingKey, val.Str()) } } if _, ok := attributes.Get(attr.AWSLocalEnvironment); !ok { - if h.defaultEnvPrefix == appsignalsconfig.PlatformECS { - if clusterName, ok := getECSClusterName(resourceAttributes); ok { - attributes.PutStr(attr.AWSLocalEnvironment, GetDefaultEnvironment(h.defaultEnvPrefix, clusterName)) + if val, found := resourceAttributes.Get(attr.AWSHostedInEnvironment); found { + attributes.PutStr(attr.AWSLocalEnvironment, val.Str()) + } else { + if h.defaultEnvPrefix == appsignalsconfig.PlatformECS { + if clusterName, ok := getECSClusterName(resourceAttributes); ok { + attributes.PutStr(attr.AWSLocalEnvironment, GetDefaultEnvironment(h.defaultEnvPrefix, clusterName)) + } } - } - if h.defaultEnvPrefix == appsignalsconfig.PlatformEC2 { - if asgAttr, ok := resourceAttributes.Get(attr.ResourceDetectionASG); ok { - attributes.PutStr(attr.AWSLocalEnvironment, GetDefaultEnvironment(h.defaultEnvPrefix, asgAttr.Str())) + if h.defaultEnvPrefix == appsignalsconfig.PlatformEC2 { + if asgAttr, ok := resourceAttributes.Get(attr.ResourceDetectionASG); ok { + attributes.PutStr(attr.AWSLocalEnvironment, GetDefaultEnvironment(h.defaultEnvPrefix, asgAttr.Str())) + } } } } diff --git a/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes.go b/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes.go index 2aa50ecc21..8dc5aea9b4 100644 --- a/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes.go +++ b/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes.go @@ -700,14 +700,11 @@ func (h *kubernetesResourceAttributesResolver) Process(attributes, resourceAttri namespace = "UnknownNamespace" } - if val, ok := resourceAttributes.Get(semconv.AttributeDeploymentEnvironment); !ok { + if val, ok := attributes.Get(attr.AWSLocalEnvironment); !ok { env := GetDefaultEnvironment(h.platformCode, h.clusterName+"/"+namespace) - if len(env) > 255 { - env = env[:255] - } - attributes.PutStr(common.MetricAttributeEnvironment, env) + attributes.PutStr(attr.AWSLocalEnvironment, env) } else { - attributes.PutStr(common.MetricAttributeEnvironment, val.Str()) + attributes.PutStr(attr.AWSLocalEnvironment, val.Str()) } attributes.PutStr(common.AttributeK8SNamespace, namespace) diff --git a/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes_test.go b/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes_test.go index b3a81634c2..42c037c319 100644 --- a/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes_test.go +++ b/plugins/processors/awsapplicationsignals/internal/resolver/kubernetes_test.go @@ -855,7 +855,7 @@ func TestK8sResourceAttributesResolverOnEKS(t *testing.T) { map[string]string{}, map[string]string{ - common.MetricAttributeEnvironment: "eks:test-cluster/test-namespace-3", + attr.AWSLocalEnvironment: "eks:test-cluster/test-namespace-3", common.AttributeK8SNamespace: "test-namespace-3", common.AttributeEKSClusterName: "test-cluster", common.AttributeEC2InstanceId: "instance-id", @@ -869,7 +869,7 @@ func TestK8sResourceAttributesResolverOnEKS(t *testing.T) { semconv.AttributeDeploymentEnvironment: "custom-env", }, map[string]string{ - common.MetricAttributeEnvironment: "custom-env", + attr.AWSLocalEnvironment: "custom-env", common.AttributeK8SNamespace: "test-namespace-3", common.AttributeEKSClusterName: "test-cluster", common.AttributeEC2InstanceId: "instance-id", @@ -932,7 +932,7 @@ func TestK8sResourceAttributesResolverOnK8S(t *testing.T) { map[string]string{}, map[string]string{ - common.MetricAttributeEnvironment: "k8s:test-cluster/test-namespace-3", + attr.AWSLocalEnvironment: "k8s:test-cluster/test-namespace-3", common.AttributeK8SNamespace: "test-namespace-3", common.AttributeK8SClusterName: "test-cluster", common.AttributeEC2InstanceId: "instance-id", @@ -946,7 +946,7 @@ func TestK8sResourceAttributesResolverOnK8S(t *testing.T) { semconv.AttributeDeploymentEnvironment: "custom-env", }, map[string]string{ - common.MetricAttributeEnvironment: "custom-env", + attr.AWSLocalEnvironment: "custom-env", common.AttributeK8SNamespace: "test-namespace-3", common.AttributeK8SClusterName: "test-cluster", common.AttributeEC2InstanceId: "instance-id", @@ -1006,10 +1006,10 @@ func TestK8sResourceAttributesResolverOnK8SOnPrem(t *testing.T) { map[string]string{}, map[string]string{ - common.MetricAttributeEnvironment: "k8s:test-cluster/test-namespace-3", - common.AttributeK8SNamespace: "test-namespace-3", - common.AttributeK8SClusterName: "test-cluster", - attr.ResourceDetectionHostName: "hostname", + attr.AWSLocalEnvironment: "k8s:test-cluster/test-namespace-3", + common.AttributeK8SNamespace: "test-namespace-3", + common.AttributeK8SClusterName: "test-cluster", + attr.ResourceDetectionHostName: "hostname", }, }, { @@ -1018,10 +1018,10 @@ func TestK8sResourceAttributesResolverOnK8SOnPrem(t *testing.T) { semconv.AttributeDeploymentEnvironment: "custom-env", }, map[string]string{ - common.MetricAttributeEnvironment: "custom-env", - common.AttributeK8SNamespace: "test-namespace-3", - common.AttributeK8SClusterName: "test-cluster", - attr.ResourceDetectionHostName: "hostname", + attr.AWSLocalEnvironment: "custom-env", + common.AttributeK8SNamespace: "test-namespace-3", + common.AttributeK8SClusterName: "test-cluster", + attr.ResourceDetectionHostName: "hostname", }, }, }