Skip to content

Commit 66abb8e

Browse files
authored
Add resource copy test validation (#401)
*Issue description:* We recently added logic to CWA to support copying resource attributes to exported EMF records, so we need to validate this logic. *Description of changes:* Update two tests (changes are not language- or platform- dependent) to specify resource attribute that triggers copy logic in CWA. Update validators to assert behaviour is as expected (resource attributes show up in EMF logs). *Rollback procedure:* We can safely revert this commit if needed. *Ensure you've run the following tests on your changes and include the link below:* Testing from CWA repo, since changes are merged but not released: * Made branch `resource-attributes` * Modified [application-signals-e2e-test.yml](https://github.com/aws/amazon-cloudwatch-agent/blob/resource-attributes/.github/workflows/application-signals-e2e-test.yml) to run only modified tests (plus python counterparts to show no regressions there) and not run on main build. * Ran [Build Test Artifacts](https://github.com/aws/amazon-cloudwatch-agent/actions/runs/14934259435) with arg `resource-attributes` - DONE * Above workflow ran [Application Signals E2E Test](https://github.com/aws/amazon-cloudwatch-agent/actions/runs/14934518108) - DONE (SUCCESS) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 2438fb9 commit 66abb8e

18 files changed

+78
-18
lines changed

terraform/java/ec2/asg/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ resource "aws_launch_configuration" "launch_configuration" {
134134
OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics \
135135
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
136136
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces \
137-
OTEL_RESOURCE_ATTRIBUTES=service.name=sample-application-${var.test_id} \
137+
OTEL_RESOURCE_ATTRIBUTES=service.name=sample-application-${var.test_id},aws.application_signals.metric_resource_keys=all_attributes \
138138
OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \
139139
nohup java -jar -XX:+UseG1GC main-service.jar &> nohup.out &
140140

terraform/java/ec2/default/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ resource "null_resource" "main_service_setup" {
144144
OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT=http://localhost:4316/v1/metrics \
145145
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
146146
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4316/v1/traces \
147-
OTEL_RESOURCE_ATTRIBUTES=service.name=sample-application-${var.test_id} \
147+
OTEL_RESOURCE_ATTRIBUTES="service.name=sample-application-${var.test_id},Internal_Org=Financial,Business Unit=Payments,Region=us-east-1,aws.application_signals.metric_resource_keys=Business Unit&Region&Organization" \
148148
OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \
149149
nohup java -XX:+UseG1GC -jar main-service.jar &> nohup.out &
150150

validator/src/main/resources/expected-data-template/java/ec2/asg/aws-sdk-call-log.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"Operation": "GET /aws-sdk-call",
77
"Version": "^1$",
88
"Telemetry.Source": "^LocalRootSpan$",
9-
"Host": "^{{privateDnsName}}$"
9+
"Host": "^{{privateDnsName}}$",
10+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
11+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
12+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
1013
},
1114
{
1215
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
@@ -20,5 +23,8 @@
2023
"RemoteResourceIdentifier": "^e2e-test-bucket-name-{{testingId}}$",
2124
"RemoteResourceType": "^AWS::S3::Bucket$",
2225
"Telemetry.Source": "^ClientSpan$",
23-
"Host": "^{{privateDnsName}}$"
26+
"Host": "^{{privateDnsName}}$",
27+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
28+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
29+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
2430
}]

validator/src/main/resources/expected-data-template/java/ec2/asg/aws-sdk-call-trace.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"default": {
2222
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
2323
"EC2.InstanceId": "^{{instanceId}}$",
24+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
2425
"otel.resource.ec2.tag.aws:autoscaling:groupName": "^{{platformInfo}}$",
2526
"otel.resource.host.id": "^{{instanceId}}$",
2627
"otel.resource.host.image.id": "^{{instanceAmi}}$",

validator/src/main/resources/expected-data-template/java/ec2/asg/client-call-log.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"Operation": "InternalOperation",
77
"Version": "^1$",
88
"Telemetry.Source": "^LocalRootSpan$",
9-
"Host": "^{{privateDnsName}}$"
9+
"Host": "^{{privateDnsName}}$",
10+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
11+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
12+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
1013
},
1114
{
1215
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
@@ -18,5 +21,8 @@
1821
"RemoteService": "local-root-client-call",
1922
"RemoteOperation": "GET /",
2023
"Telemetry.Source": "^ClientSpan$",
21-
"Host": "^{{privateDnsName}}$"
24+
"Host": "^{{privateDnsName}}$",
25+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
26+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
27+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
2228
}]

validator/src/main/resources/expected-data-template/java/ec2/asg/client-call-trace.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"metadata": {
99
"default": {
10+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
1011
"otel.resource.ec2.tag.aws:autoscaling:groupName": "^{{platformInfo}}$",
1112
"otel.resource.host.id": "^{{instanceId}}$",
1213
"otel.resource.host.image.id": "^{{instanceAmi}}$",

validator/src/main/resources/expected-data-template/java/ec2/asg/outgoing-http-call-log.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"Operation": "GET /outgoing-http-call",
77
"Version": "^1$",
88
"Telemetry.Source": "^LocalRootSpan$",
9-
"Host": "^{{privateDnsName}}$"
9+
"Host": "^{{privateDnsName}}$",
10+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
11+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
12+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
1013
},
1114
{
1215
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
@@ -18,5 +21,8 @@
1821
"RemoteService": "www.amazon.com",
1922
"RemoteOperation": "GET /",
2023
"Telemetry.Source": "^ClientSpan$",
21-
"Host": "^{{privateDnsName}}$"
24+
"Host": "^{{privateDnsName}}$",
25+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
26+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
27+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
2228
}]

validator/src/main/resources/expected-data-template/java/ec2/asg/outgoing-http-call-trace.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"default": {
2222
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
2323
"EC2.InstanceId": "^{{instanceId}}$",
24+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
2425
"otel.resource.ec2.tag.aws:autoscaling:groupName": "^{{platformInfo}}$",
2526
"otel.resource.host.id": "^{{instanceId}}$",
2627
"otel.resource.host.image.id": "^{{instanceAmi}}$",

validator/src/main/resources/expected-data-template/java/ec2/asg/remote-service-log.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"Operation": "GET /remote-service",
77
"Version": "^1$",
88
"Telemetry.Source": "^LocalRootSpan$",
9-
"Host": "^{{privateDnsName}}$"
9+
"Host": "^{{privateDnsName}}$",
10+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
11+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
12+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
1013
},
1114
{
1215
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
@@ -18,5 +21,8 @@
1821
"RemoteService": "{{remoteServiceDeploymentName}}",
1922
"RemoteOperation": "GET /healthcheck",
2023
"Telemetry.Source": "^ClientSpan$",
21-
"Host": "^{{privateDnsName}}$"
24+
"Host": "^{{privateDnsName}}$",
25+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
26+
"otel.resource.host.image.id": "^{{instanceAmi}}$",
27+
"otel.resource.host.type": "^([a-z0-9]+\\.[a-z0-9]+)$"
2228
}]

validator/src/main/resources/expected-data-template/java/ec2/asg/remote-service-trace.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"EC2.AutoScalingGroup": "^{{platformInfo}}$",
2323
"EC2.InstanceId": "^{{instanceId}}$",
2424
"PlatformType": "^AWS::EC2$",
25+
"otel.resource.aws.application_signals.metric_resource_keys": "all_attributes",
2526
"otel.resource.ec2.tag.aws:autoscaling:groupName": "^{{platformInfo}}$",
2627
"otel.resource.host.id": "^{{instanceId}}$",
2728
"otel.resource.host.image.id": "^{{instanceAmi}}$",

0 commit comments

Comments
 (0)