Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/processors/awsapplicationsignals/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const (

// Resource attributes used as CloudWatch EMF log fields.
const (
MetricAttributeRemoteDbUser = "RemoteDbUser"
MetricAttributeRemoteDbUser = "RemoteDbUser"
MetricAttributeRemoteResourceCfnPrimaryIdentifier = "RemoteResourceCfnPrimaryIdentifier"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ package attributes

const (
// aws attributes
AWSSpanKind = "aws.span.kind"
AWSLocalService = "aws.local.service"
AWSLocalEnvironment = "aws.local.environment"
AWSLocalOperation = "aws.local.operation"
AWSRemoteService = "aws.remote.service"
AWSRemoteOperation = "aws.remote.operation"
AWSRemoteEnvironment = "aws.remote.environment"
AWSRemoteTarget = "aws.remote.target"
AWSRemoteResourceIdentifier = "aws.remote.resource.identifier"
AWSRemoteResourceType = "aws.remote.resource.type"
AWSHostedInEnvironment = "aws.hostedin.environment"
AWSRemoteDbUser = "aws.remote.db.user"
AWSSpanKind = "aws.span.kind"
AWSLocalService = "aws.local.service"
AWSLocalEnvironment = "aws.local.environment"
AWSLocalOperation = "aws.local.operation"
AWSRemoteService = "aws.remote.service"
AWSRemoteOperation = "aws.remote.operation"
AWSRemoteEnvironment = "aws.remote.environment"
AWSRemoteTarget = "aws.remote.target"
AWSRemoteResourceIdentifier = "aws.remote.resource.identifier"
AWSRemoteResourceType = "aws.remote.resource.type"
AWSHostedInEnvironment = "aws.hostedin.environment"
AWSRemoteDbUser = "aws.remote.db.user"
AWSRemoteResourceCfnPrimaryIdentifier = "aws.remote.resource.cfn.primary.identifier"

// resource detection processor attributes
ResourceDetectionHostId = "host.id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ type attributesNormalizer struct {
}

var attributesRenamingForMetric = map[string]string{
attr.AWSLocalService: common.CWMetricAttributeLocalService,
attr.AWSLocalOperation: common.CWMetricAttributeLocalOperation,
attr.AWSLocalEnvironment: common.CWMetricAttributeEnvironment,
attr.AWSRemoteService: common.CWMetricAttributeRemoteService,
attr.AWSRemoteOperation: common.CWMetricAttributeRemoteOperation,
attr.AWSRemoteEnvironment: common.CWMetricAttributeRemoteEnvironment,
attr.AWSRemoteTarget: common.CWMetricAttributeRemoteResourceIdentifier,
attr.AWSRemoteResourceIdentifier: common.CWMetricAttributeRemoteResourceIdentifier,
attr.AWSRemoteResourceType: common.CWMetricAttributeRemoteResourceType,
attr.AWSRemoteDbUser: common.MetricAttributeRemoteDbUser,
attr.AWSLocalService: common.CWMetricAttributeLocalService,
attr.AWSLocalOperation: common.CWMetricAttributeLocalOperation,
attr.AWSLocalEnvironment: common.CWMetricAttributeEnvironment,
attr.AWSRemoteService: common.CWMetricAttributeRemoteService,
attr.AWSRemoteOperation: common.CWMetricAttributeRemoteOperation,
attr.AWSRemoteEnvironment: common.CWMetricAttributeRemoteEnvironment,
attr.AWSRemoteTarget: common.CWMetricAttributeRemoteResourceIdentifier,
attr.AWSRemoteResourceIdentifier: common.CWMetricAttributeRemoteResourceIdentifier,
attr.AWSRemoteResourceType: common.CWMetricAttributeRemoteResourceType,
attr.AWSRemoteDbUser: common.MetricAttributeRemoteDbUser,
attr.AWSRemoteResourceCfnPrimaryIdentifier: common.MetricAttributeRemoteResourceCfnPrimaryIdentifier,
}

var resourceAttributesRenamingForTrace = map[string]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,22 @@ func TestTruncateAttributes_AWSRemoteDbUser(t *testing.T) {
val, _ := attributes.Get(attr.AWSRemoteDbUser)
assert.True(t, len(val.Str()) <= defaultMetricAttributeLength)
}

func TestRenameAttributes_AWSRemoteResourceCfnIdentifier_for_metric(t *testing.T) {
logger, _ := zap.NewDevelopment()
normalizer := NewAttributesNormalizer(logger)

attributes := pcommon.NewMap()
attributes.PutStr(attr.AWSRemoteResourceCfnPrimaryIdentifier, "arn:123:abc-value")

resourceAttributes := pcommon.NewMap()
normalizer.renameAttributes(attributes, resourceAttributes, false)

if _, ok := attributes.Get(attr.AWSRemoteResourceCfnPrimaryIdentifier); ok {
t.Errorf("AWSRemoteResourceCfnPrimaryIdentifier was not removed")
}

if value, ok := attributes.Get("RemoteResourceCfnPrimaryIdentifier"); !ok || value.AsString() != "arn:123:abc-value" {
t.Errorf("RemoteResourceCfnPrimaryIdentifier has incorrect value: got %v, want %v", value.AsString(), "arn:123:abc-value")
}
}
Loading