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

Fallback to rpc.method for segment operation when aws.operation missing #6231

Merged

Conversation

NathanielRN
Copy link
Contributor

Description:

When creating an AWS segment, the exporter/awsxrayexporter/internal/translator/segment.go file will create the "AWS" component of the segment (a map under the "aws" key) by reading through the attributes of an OTel span.

Span generated for the AWS SDK will either have aws.operation according to legacy, or rpc.method to describes the "operation" made with the AWS SDK as explained in the specifications.

Because some languages have moved to the new spec-defined rpc.method, we update the translator to consider this attribute.

NOTE: We do not need to map rpc.service to aws.service since it is not used by the AWS X-Ray backend.

Link to tracking Issue: Fixes #6109

Testing:

Tests mostly make sure the operation (e.g. GetItem) is present in the final segment structure regardless if we are using the legacy aws.operation or the new rpc.method.

In the case where both are defined, the legacy aws.operation will take precedence as remarked by the updated legacy unit test which defines both but which takes aws.operation.

Documentation:

Not a breaking change, so N/A.

@NathanielRN NathanielRN requested a review from a team November 10, 2021 20:10
@NathanielRN NathanielRN marked this pull request as draft November 10, 2021 20:10
@NathanielRN NathanielRN marked this pull request as ready for review November 10, 2021 20:28
@NathanielRN NathanielRN force-pushed the map-rpc-values-awsxray-exporter branch from 82f3d54 to de74588 Compare November 10, 2021 20:36
@NathanielRN NathanielRN force-pushed the map-rpc-values-awsxray-exporter branch from de74588 to 7d0b686 Compare November 10, 2021 20:37
@@ -62,13 +62,15 @@ func TestClientSpanWithRpcAwsSdkClientAttributes(t *testing.T) {
segment, _ := MakeSegment(span, resource, nil, false)
assert.Equal(t, "DynamoDB", *segment.Name)
assert.Equal(t, conventions.AttributeCloudProviderAWS, *segment.Namespace)
assert.Equal(t, "GetItem", *segment.AWS.Operation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add the case to aws_test.go?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's an excellent suggestion! I added a test case like this one just to test that rpc.method is read:

func TestAwsWithRpcAttributes(t *testing.T) {
	resource := pdata.NewResource()
	attributes := make(map[string]pdata.AttributeValue)
	attributes[conventions.AttributeRPCMethod] = pdata.NewAttributeValueString("ListBuckets")

	_, awsData := makeAws(attributes, resource)

	assert.NotNil(t, awsData)
	assert.Equal(t, "ListBuckets", *awsData.Operation)
}

and added this following above the line you linked to test the case where they are both defined:

attributes[conventions.AttributeRPCMethod] = pdata.NewAttributeValueString("IncorrectAWSSDKOperation")

@NathanielRN NathanielRN requested a review from anuraaga November 11, 2021 00:57
@alolita
Copy link
Member

alolita commented Nov 11, 2021

@tigrannajaryan @kbrockhoff @Aneurysm9 - can you please provide a second review so that this PR can be merged and be available in the next Collector release. We have a downstream dependency on this. Many thx!

@tigrannajaryan tigrannajaryan merged commit 46aeefc into open-telemetry:main Nov 12, 2021
@tigrannajaryan
Copy link
Member

Please populate the commit message in future PRs. Don't just write one-line commit message.

@NathanielRN NathanielRN deleted the map-rpc-values-awsxray-exporter branch November 12, 2021 16:26
povilasv referenced this pull request in coralogix/opentelemetry-collector-contrib Dec 19, 2022
)

Officially this can be considered breaking change because of a use in a `var foo func(interface{}) error = conf.Unmarshal`, not in a normal calling usage, but this is an edgecase that we can except and move forward with this.

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS X-Ray Exporter should map rpc values to aws values
5 participants