Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/awsxray] Favour semconv attributes for QueueURL and TableName #16076

Merged
merged 3 commits into from
Nov 11, 2022
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
16 changes: 16 additions & 0 deletions .chloggen/exporter-awsxray-semconv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: exporter/awsxrayexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Favour semantic convention attributes for DynamoDB table name and messaging url when translating OTel data into X-Ray AWS data.

# One or more tracking issues related to the change
issues: [16075]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
8 changes: 8 additions & 0 deletions exporter/awsxrayexporter/internal/translator/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ func makeAws(attributes map[string]pcommon.Value, resource pcommon.Resource) (ma
return filtered, nil // not AWS so return nil
}

// Favor Semantic Conventions for specific SQS and DynamoDB attributes.
if value, ok := attributes[conventions.AttributeMessagingURL]; ok {
mx-psi marked this conversation as resolved.
Show resolved Hide resolved
queueURL = value.Str()
}
if value, ok := attributes[conventions.AttributeAWSDynamoDBTableNames]; ok {
tableName = value.Str()
}

// EC2 - add ec2 metadata to xray request if
// 1. cloud.platfrom is set to "aws_ec2" or
// 2. there is an non-blank host/instance id found
Expand Down
24 changes: 24 additions & 0 deletions exporter/awsxrayexporter/internal/translator/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ func TestAwsWithSqsAlternateAttribute(t *testing.T) {
assert.Equal(t, queueURL, *awsData.QueueURL)
}

func TestAwsWithAwsSqsSemConvAttributes(t *testing.T) {
queueURL := "https://sqs.use1.amazonaws.com/Meltdown-Alerts"
attributes := make(map[string]pcommon.Value)
attributes[conventions.AttributeMessagingURL] = pcommon.NewValueStr(queueURL)

filtered, awsData := makeAws(attributes, pcommon.NewResource())

assert.NotNil(t, filtered)
assert.NotNil(t, awsData)
assert.Equal(t, queueURL, *awsData.QueueURL)
}

func TestAwsWithAwsDynamoDbResources(t *testing.T) {
instanceID := "i-00f7c0bcb26da2a99"
containerName := "signup_aggregator-x82ufje83"
Expand Down Expand Up @@ -290,6 +302,18 @@ func TestAwsWithDynamoDbAlternateAttribute(t *testing.T) {
assert.Equal(t, tableName, *awsData.TableName)
}

func TestAwsWithDynamoDbSemConvAttributes(t *testing.T) {
tableName := "MyTable"
attributes := make(map[string]pcommon.Value)
attributes[conventions.AttributeAWSDynamoDBTableNames] = pcommon.NewValueStr(tableName)

filtered, awsData := makeAws(attributes, pcommon.NewResource())

assert.NotNil(t, filtered)
assert.NotNil(t, awsData)
assert.Equal(t, tableName, *awsData.TableName)
}

func TestAwsWithRequestIdAlternateAttribute(t *testing.T) {
requestid := "12345-request"
attributes := make(map[string]pcommon.Value)
Expand Down