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

Add EKS integration testing for APM Traces #327

Closed
wants to merge 18 commits into from
Closed

Add EKS integration testing for APM Traces #327

wants to merge 18 commits into from

Conversation

lisguo
Copy link
Contributor

@lisguo lisguo commented Aug 7, 2023

Description of the issue

  • Add integration test to test traces sent to otlp receiver of the cw agent to the xray backend

Description of changes

  • Creates a golang container with a script for generating the trace id, and sending the trace to the node endpoint on a pod in an EKS cluster
  • Performs validation by checking the following annotations in the last 50 minutes. Open to ideas on how to best capture the start timestamp of the terraform
"annotations": {
                    "aws_remote_target": "remote-target",
                    "aws_remote_operation": "remote-operation",
                    "aws_local_service": "service-name",
                    "aws_remote_service": "service-name-remote",
                    "K8s_Namespace": "default",
                    "EKS_Cluster": "cwagent-eks-integ-800b3d9748c1443a",
                    "aws_local_operation": "operation"
                },

Was hoping to get this CR merged in first but can refactor afterwards - https://github.com/aws/amazon-cloudwatch-agent-test/pull/318/files

I took some functions from this CR for validation logic.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Succeeded test - https://github.com/aws/private-amazon-cloudwatch-agent-staging/actions/runs/5777874930/job/15660745029

@lisguo lisguo requested a review from a team as a code owner August 7, 2023 13:57
@lisguo lisguo changed the title Apm traces Add EKS integration testing for APM Traces Aug 7, 2023
@@ -48,4 +48,5 @@ var (
DynamodbClient = dynamodb.NewFromConfig(awsCfg)
S3Client = s3.NewFromConfig(awsCfg)
CloudformationClient = cloudformation.NewFromConfig(awsCfg)
XrayClient = xray.NewFromConfig(awsCfg)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why this didn't format correctly...it's lined up on my local.

}
}
command = [
"/bin/sh",
"-c",
"while true; do echo '${data.template_file.server_consumer.rendered}' | sed -e \"s/START_TIME/$(date +%s%N)/\" > server_consumer.json; curl -H 'Content-Type: application/json' -d @server_consumer.json -i http://127.0.0.1:4318/v1/metrics --verbose --http0.9; echo '${data.template_file.client_producer.rendered}' | sed -e \"s/START_TIME/$(date +%s%N)/\" > client_producer.json; curl -H 'Content-Type: application/json' -d @client_producer.json -i http://127.0.0.1:4318/v1/metrics --verbose --http0.9; sleep 1; done"
"while true; echo '${data.template_file.traceid_generator.rendered}' > traceid_generator.go && chmod +x traceid_generator.go; export START_TIME=$(date +%s%N); export TRACE_ID=$(go run ./traceid_generator.go); do echo '${data.template_file.server_consumer.rendered}' | sed -e \"s/START_TIME/$START_TIME/\" > server_consumer.json; curl -H 'Content-Type: application/json' -d @server_consumer.json -i http://127.0.0.1:4318/v1/metrics --verbose; echo '${data.template_file.client_producer.rendered}' | sed -e \"s/START_TIME/$START_TIME/\" > client_producer.json; curl -H 'Content-Type: application/json' -d @client_producer.json -i http://127.0.0.1:4318/v1/metrics --verbose; echo '${data.template_file.traces.rendered}' | sed -e \"s/START_TIME/$START_TIME/\" | sed -e \"s/TRACE_ID/$TRACE_ID/\" > traces.json; curl -H 'Content-Type: application/json' -d @traces.json -i http://127.0.0.1:4318/v1/traces --verbose; sleep 1; done"
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand what this is doing, but I think it's still hard to follow. Can we build the generator?

nit: There has to be a better way to mount the files you need to run in this container instead of the template rendering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah ideally we can build the generator bin, and mount it on a volume along with the other json files. The templating comes from the metric tests which I've borrowed.

I could try to spend some time to make this cleaner and easier to follow

Comment on lines +425 to +429
data "template_file" "traces" {
template = file(local.traces)
vars = {
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Use local_file instead of template_file if it isn't templating anything.

Suggested change
data "template_file" "traces" {
template = file(local.traces)
vars = {
}
}
data "local_file" "traces" {
filename = local.traces
}

"time"
)

func main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that this is probably to avoid dependencies, but https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/propagators/aws/xray provides an ID generator, which is what customers would be using as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh nice! I can look into this

@lisguo lisguo closed this Oct 25, 2023
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.

3 participants