Skip to content

Commit

Permalink
[exporter/awsxray] Favour semconv attributes for QueueURL and TableNa…
Browse files Browse the repository at this point in the history
…me (open-telemetry#16076)

* [exporter/awsxray] Favour semconv attributes when populating Queue URL and Table Name

* Fix linter complaint about spelling

* Reinstate redundant test code
  • Loading branch information
lukestoward authored and MovieStoreGuy committed Nov 16, 2022
1 parent 0ed1161 commit 585d710
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
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 {
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

0 comments on commit 585d710

Please sign in to comment.