Skip to content

Commit 15d43fb

Browse files
Jeel-mehtaJeel Mehtaharrryr
authored
[Java] SigV4 logs release testing (#412)
*Issue description:* This PR implements and validates SigV4 log functionality for Java EC2 ADOT (Stand-Alone ADOT) use case. The implementation focuses on validating logs sent to the `otlp_logs` log group, ensuring a consistent and reliable validation approach that can be replicated across different language implementations. *Description of changes:* 1. Updated Terraform configuration: - Added OTLP logs exporter configuration - Updated environment variables for SigV4 authentication 2. Added validation resources: - Created new log.mustache template for SigV4 logs validation - Added log-validation.yml configuration - Updated PredefinedExpectedTemplate.java to include SigV4 logs template - Modified CWLogValidator.java to support SigV4 logs validation 3. Workflow Updates: - Added new validation step for SigV4 logs - Configured TEST_LOG_GROUP_NAME environment variable *Rollback procedure:* 1. Reverting the Terraform configuration changes 2. Removing the added validation files and code changes 3. Removing the SigV4 logs validation step from the workflow Test run- For [Java](https://github.com/aws-observability/aws-application-signals-test-framework/actions/runs/15570274548) Also Validating for [Python](https://github.com/aws-observability/aws-application-signals-test-framework/actions/runs/15450029203) as the filter pattern was changed in the CWLogValidator.java <Can we safely revert this commit if needed? If not, detail what must be done to safely revert and why it is needed.> *Ensure you've run the following tests on your changes and include the link below:* To do so, create a `test.yml` file with `name: Test` and workflow description to test your changes, then remove the file for your PR. Link your test run in your PR description. This process is a short term solution while we work on creating a staging environment for testing. NOTE: TESTS RUNNING ON A SINGLE EKS CLUSTER CANNOT BE RUN IN PARALLEL. See the [needs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds) keyword to run tests in succession. - Run Java EKS on `e2e-playground` in us-east-1 and eu-central-2 - Run Python EKS on `e2e-playground` in us-east-1 and eu-central-2 - Run metric limiter on EKS cluster `e2e-playground` in us-east-1 and eu-central-2 - Run EC2 tests in all regions - Run K8s on a separate K8s cluster (check IAD test account for master node endpoints; these will change as we create and destroy clusters for OS patching) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Jeel Mehta <[email protected]> Co-authored-by: Harry <[email protected]>
1 parent 66abb8e commit 15d43fb

22 files changed

+73
-26
lines changed

.github/workflows/java-ec2-adot-sigv4-test.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ env:
4141
CPU_ARCHITECTURE: ${{ inputs.cpu-architecture }}
4242
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }} # us-east-1 test account
4343
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
44-
LOG_GROUP_NAME: aws/spans
44+
SPANS_LOG_GROUP_NAME: aws/spans
45+
APPLICATION_LOGS_LOG_GROUP_NAME: otlp_logs # This log group was created manually to store application logs
4546
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}
4647

4748
jobs:
@@ -128,6 +129,7 @@ jobs:
128129
-var="get_adot_jar_command=${{ env.GET_ADOT_JAR_COMMAND }}" \
129130
-var="language_version=${{ env.JAVA_VERSION }}" \
130131
-var="cpu_architecture=${{ env.CPU_ARCHITECTURE }}" \
132+
-var="application_logs_log_group=${{ env.APPLICATION_LOGS_LOG_GROUP_NAME }}" \
131133
|| deployment_failed=$?
132134
133135
if [ $deployment_failed -eq 1 ]; then
@@ -178,14 +180,14 @@ jobs:
178180
# Validation for pulse telemetry data
179181
- name: Validate generated EMF logs
180182
id: log-validation
181-
run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/log-validation.yml
183+
run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/log-validation.yml
182184
--testing-id ${{ env.TESTING_ID }}
183185
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
184186
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
185187
--region ${{ env.E2E_TEST_AWS_REGION }}
186188
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
187189
--metric-namespace ${{ env.METRIC_NAMESPACE }}
188-
--log-group ${{ env.LOG_GROUP_NAME }}
190+
--log-group ${{ env.SPANS_LOG_GROUP_NAME }}
189191
--service-name sample-application-${{ env.TESTING_ID }}
190192
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
191193
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
@@ -196,14 +198,14 @@ jobs:
196198
- name: Validate generated metrics
197199
id: metric-validation
198200
if: (success() || steps.log-validation.outcome == 'failure') && !cancelled()
199-
run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/metric-validation.yml
201+
run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/metric-validation.yml
200202
--testing-id ${{ env.TESTING_ID }}
201203
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
202204
--remote-service-deployment-name sample-remote-application-${{ env.TESTING_ID }}
203205
--region ${{ env.E2E_TEST_AWS_REGION }}
204206
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
205207
--metric-namespace ${{ env.METRIC_NAMESPACE }}
206-
--log-group ${{ env.LOG_GROUP_NAME }}
208+
--log-group ${{ env.SPANS_LOG_GROUP_NAME }}
207209
--service-name sample-application-${{ env.TESTING_ID }}
208210
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
209211
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
@@ -214,20 +216,37 @@ jobs:
214216
- name: Validate generated traces
215217
id: trace-validation
216218
if: (success() || steps.log-validation.outcome == 'failure' || steps.metric-validation.outcome == 'failure') && !cancelled()
217-
run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/trace-validation.yml
219+
run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/trace-validation.yml
218220
--testing-id ${{ env.TESTING_ID }}
219221
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
220222
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
221223
--region ${{ env.E2E_TEST_AWS_REGION }}
222224
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
223225
--metric-namespace ${{ env.METRIC_NAMESPACE }}
224-
--log-group ${{ env.LOG_GROUP_NAME }}
226+
--log-group ${{ env.SPANS_LOG_GROUP_NAME }}
225227
--service-name sample-application-${{ env.TESTING_ID }}
226228
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
227229
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
228230
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
229231
--instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }}
230232
--rollup'
233+
234+
- name: Validate generated otlp logs
235+
id: application-log-validation
236+
run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/application-log-validation.yml
237+
--testing-id ${{ env.TESTING_ID }}
238+
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
239+
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
240+
--region ${{ env.E2E_TEST_AWS_REGION }}
241+
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
242+
--metric-namespace ${{ env.METRIC_NAMESPACE }}
243+
--log-group ${{ env.APPLICATION_LOGS_LOG_GROUP_NAME }}
244+
--service-name sample-application-${{ env.TESTING_ID }}
245+
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
246+
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
247+
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
248+
--instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }}
249+
--rollup'
231250

232251
- name: Refresh AWS Credentials
233252
if: ${{ github.event.repository.name == 'aws-application-signals-test-framework' }}

terraform/java/ec2/adot-sigv4/main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,14 @@ resource "null_resource" "main_service_setup" {
132132
133133
# OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \
134134
export JAVA_TOOL_OPTIONS=' -javaagent:/home/ec2-user/adot.jar'
135-
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=false
136-
export OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true
137-
export OTEL_LOGS_EXPORT=none
135+
export OTEL_LOGS_EXPORTER=otlp
138136
export OTEL_METRICS_EXPORTER=none
139137
export OTEL_TRACES_EXPORTER=otlp
140138
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
139+
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
141140
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://xray.${var.aws_region}.amazonaws.com/v1/traces
141+
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs.${var.aws_region}.amazonaws.com/v1/logs
142+
export OTEL_EXPORTER_OTLP_LOGS_HEADERS=x-aws-log-group=${var.application_logs_log_group},x-aws-log-stream=default
142143
export OTEL_RESOURCE_ATTRIBUTES=service.name=sample-application-${var.test_id}
143144
nohup java -jar main-service.jar &> nohup.out &
144145
@@ -222,13 +223,14 @@ resource "null_resource" "remote_service_setup" {
222223
223224
# OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \
224225
export JAVA_TOOL_OPTIONS=' -javaagent:/home/ec2-user/adot.jar'
225-
export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=false
226-
export OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true
227-
export OTEL_LOGS_EXPORT=none
226+
export OTEL_LOGS_EXPORTER=otlp
228227
export OTEL_METRICS_EXPORTER=none
229228
export OTEL_TRACES_EXPORTER=otlp
230229
export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
230+
export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
231231
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://xray.${var.aws_region}.amazonaws.com/v1/traces
232+
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs.${var.aws_region}.amazonaws.com/v1/logs
233+
export OTEL_EXPORTER_OTLP_LOGS_HEADERS=x-aws-log-group=${var.application_logs_log_group},x-aws-log-stream=default
232234
OTEL_RESOURCE_ATTRIBUTES=service.name=sample-remote-application-${var.test_id} \
233235
nohup java -jar remote-service.jar &> nohup.out &
234236

terraform/java/ec2/adot-sigv4/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ variable "language_version" {
4747

4848
variable "cpu_architecture" {
4949
default = "x86_64"
50+
}
51+
52+
variable "application_logs_log_group" {
53+
default = "otlp_logs"
5054
}

validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,26 @@ public enum PredefinedExpectedTemplate implements FileConfig {
116116
JAVA_EC2_UBUNTU_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/ubuntu/client-call-trace.mustache"),
117117

118118
/** Java EC2 ADOT SigV4 (ADOT Stand-Alone) Test Case Validations */
119-
JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-log.mustache"),
119+
JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-log.mustache"),
120120
JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_METRIC(
121-
"/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-metric.mustache"),
121+
"/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-metric.mustache"),
122122
JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_TRACE(
123-
"/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-trace.mustache"),
123+
"/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-trace.mustache"),
124124

125-
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-log.mustache"),
126-
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_METRIC("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-metric.mustache"),
127-
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_TRACE("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-trace.mustache"),
125+
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-log.mustache"),
126+
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-metric.mustache"),
127+
JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-trace.mustache"),
128128

129-
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_LOG("/expected-data-template/java/ec2/adot-sigv4/remote-service-log.mustache"),
130-
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_METRIC("/expected-data-template/java/ec2/adot-sigv4/remote-service-metric.mustache"),
131-
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_TRACE("/expected-data-template/java/ec2/adot-sigv4/remote-service-trace.mustache"),
129+
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_LOG("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-log.mustache"),
130+
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-metric.mustache"),
131+
JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-trace.mustache"),
132132

133-
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/client-call-log.mustache"),
134-
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_METRIC("/expected-data-template/java/ec2/adot-sigv4/client-call-metric.mustache"),
135-
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/adot-sigv4/client-call-trace.mustache"),
133+
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/client-call-log.mustache"),
134+
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/client-call-metric.mustache"),
135+
JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/client-call-trace.mustache"),
136+
137+
/** Java EC2 ADOT SigV4 Log Exporter Test Case Validation */
138+
JAVA_EC2_ADOT_OTLP_LOG("/expected-data-template/java/ec2/adot-aws-otlp/application-log.mustache"),
136139

137140
/** Java EC2 K8s Test Case Validations */
138141
JAVA_K8S_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/k8s/outgoing-http-call-log.mustache"),

validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private Map<String, Object> getActualOtelSpanLog(String operation, String remote
236236

237237
private Map<String, Object> getActualAwsOtlpLog() throws Exception {
238238
String filterPattern= String.format(
239-
"{ ($.attributes.otelServiceName = \"%s\") && ($.body = \"This is a custom log for validation testing\") }",
239+
"{ ($.resource.attributes.['service.name'] = \"%s\") && ($.body = \"This is a custom log for validation testing\") }",
240240
context.getServiceName()
241241
);
242242
log.info("Filter Pattern for OTLP Log Search: " + filterPattern);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[{
2+
"resource": {
3+
"attributes": {
4+
"service.name": "{{serviceName}}",
5+
"cloud.provider": "aws",
6+
"cloud.region": "{{region}}",
7+
"cloud.account.id": "{{accountId}}",
8+
"cloud.platform": "aws_ec2"
9+
}
10+
},
11+
"severityNumber": "^[0-9]+$",
12+
"severityText": "{{severityText}}",
13+
"body": "This is a custom log for validation testing",
14+
"traceId": "{{traceId}}",
15+
"spanId": "{{spanId}}"
16+
}]

0 commit comments

Comments
 (0)