Skip to content

[receiver/awsxray] Set cloudwatch logs metadata in attributes. #188

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

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

jefchien
Copy link

Description:

From the issue:

X-Ray segments have a few optional fields that carry AWS resource data. As part of the translation of X-Ray segments to spans, the translator extracts AWS data and puts them in the resource attributes. It does this for EC2, ECS, Beanstalk, and EKS, but not for CloudWatch Logs. So, by the time the span reaches the exporter, that information is lost.

This change adds the cloudwatch logs metadata to the attributes with the keys conventions.AttributeAWSLogGroupARNs and conventions.AttributeAWSLogGroupNames. Both of these are used by the awsxrayexporter to restore the LogGroupMetadata.

case conventions.AttributeAWSLogGroupNames:
logGroups = normalizeToSlice(value)
case conventions.AttributeAWSLogGroupARNs:
logGroupArns = normalizeToSlice(value)

func getLogGroupMetadata(logGroups pcommon.Slice, isArn bool) []awsxray.LogGroupMetadata {
var lgm []awsxray.LogGroupMetadata
for i := 0; i < logGroups.Len(); i++ {
if isArn {
lgm = append(lgm, awsxray.LogGroupMetadata{
Arn: awsxray.String(logGroups.At(i).Str()),
LogGroup: awsxray.String(parseLogGroup(logGroups.At(i).Str())),
})
} else {
lgm = append(lgm, awsxray.LogGroupMetadata{
LogGroup: awsxray.String(logGroups.At(i).Str()),
})
}
}
return lgm
}

Link to tracking Issue: open-telemetry#31784, aws/amazon-cloudwatch-agent#1097

Testing: Added unit tests to validate the translation to resource attributes.

@jefchien jefchien requested a review from wangzlei as a code owner March 22, 2024 17:14
Copy link

github-actions bot commented Apr 6, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 6, 2024
@jefchien jefchien merged commit da405ec into aws-cwa-dev Apr 9, 2024
64 of 77 checks passed
@jefchien jefchien deleted the fix-cwlogs-xray branch April 9, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants