diff --git a/.github/workflows/java-ec2-adot-sigv4-test.yml b/.github/workflows/java-ec2-adot-sigv4-test.yml index ca36941e8..01070e939 100644 --- a/.github/workflows/java-ec2-adot-sigv4-test.yml +++ b/.github/workflows/java-ec2-adot-sigv4-test.yml @@ -42,6 +42,7 @@ env: E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }} # us-east-1 test account E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }} LOG_GROUP_NAME: aws/spans + TEST_LOG_GROUP_NAME: otlp_logs TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE} jobs: @@ -128,6 +129,7 @@ jobs: -var="get_adot_jar_command=${{ env.GET_ADOT_JAR_COMMAND }}" \ -var="language_version=${{ env.JAVA_VERSION }}" \ -var="cpu_architecture=${{ env.CPU_ARCHITECTURE }}" \ + -var="test_log_group=${{ env.TEST_LOG_GROUP_NAME }}" \ || deployment_failed=$? if [ $deployment_failed -eq 1 ]; then @@ -178,7 +180,7 @@ jobs: # Validation for pulse telemetry data - name: Validate generated EMF logs id: log-validation - run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/log-validation.yml + run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/log-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 @@ -196,7 +198,7 @@ jobs: - name: Validate generated metrics id: metric-validation if: (success() || steps.log-validation.outcome == 'failure') && !cancelled() - run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/metric-validation.yml + run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/metric-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name sample-remote-application-${{ env.TESTING_ID }} @@ -214,7 +216,7 @@ jobs: - name: Validate generated traces id: trace-validation if: (success() || steps.log-validation.outcome == 'failure' || steps.metric-validation.outcome == 'failure') && !cancelled() - run: ./gradlew validator:run --args='-c java/ec2/adot-sigv4/trace-validation.yml + run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/trace-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 @@ -228,6 +230,23 @@ jobs: --instance-ami ${{ env.EC2_INSTANCE_AMI }} --instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }} --rollup' + + - name: Validate generated otlp logs + id: application-log-validation + run: ./gradlew validator:run --args='-c java/ec2/adot-aws-otlp/logs/application-log-validation.yml + --testing-id ${{ env.TESTING_ID }} + --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} + --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 + --region ${{ env.E2E_TEST_AWS_REGION }} + --account-id ${{ env.E2E_TEST_ACCOUNT_ID }} + --metric-namespace ${{ env.METRIC_NAMESPACE }} + --log-group ${{ env.TEST_LOG_GROUP_NAME }} + --service-name sample-application-${{ env.TESTING_ID }} + --remote-service-name sample-remote-application-${{ env.TESTING_ID }} + --query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }} + --instance-ami ${{ env.EC2_INSTANCE_AMI }} + --instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }} + --rollup' - name: Refresh AWS Credentials if: ${{ github.event.repository.name == 'aws-application-signals-test-framework' }} diff --git a/terraform/java/ec2/adot-sigv4/main.tf b/terraform/java/ec2/adot-sigv4/main.tf index d1ced938a..514133465 100644 --- a/terraform/java/ec2/adot-sigv4/main.tf +++ b/terraform/java/ec2/adot-sigv4/main.tf @@ -132,13 +132,14 @@ resource "null_resource" "main_service_setup" { # OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \ export JAVA_TOOL_OPTIONS=' -javaagent:/home/ec2-user/adot.jar' - export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=false - export OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true - export OTEL_LOGS_EXPORT=none + export OTEL_LOGS_EXPORTER=otlp export OTEL_METRICS_EXPORTER=none export OTEL_TRACES_EXPORTER=otlp export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf + export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://xray.${var.aws_region}.amazonaws.com/v1/traces + export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs.${var.aws_region}.amazonaws.com/v1/logs + export OTEL_EXPORTER_OTLP_LOGS_HEADERS=x-aws-log-group=${var.test_log_group},x-aws-log-stream=default export OTEL_RESOURCE_ATTRIBUTES=service.name=sample-application-${var.test_id} nohup java -jar main-service.jar &> nohup.out & @@ -222,13 +223,14 @@ resource "null_resource" "remote_service_setup" { # OTEL_INSTRUMENTATION_COMMON_EXPERIMENTAL_CONTROLLER_TELEMETRY_ENABLED=true \ export JAVA_TOOL_OPTIONS=' -javaagent:/home/ec2-user/adot.jar' - export OTEL_AWS_APPLICATION_SIGNALS_ENABLED=false - export OTEL_RESOURCE_PROVIDERS_AWS_ENABLED=true - export OTEL_LOGS_EXPORT=none + export OTEL_LOGS_EXPORTER=otlp export OTEL_METRICS_EXPORTER=none export OTEL_TRACES_EXPORTER=otlp export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf + export OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://xray.${var.aws_region}.amazonaws.com/v1/traces + export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs.${var.aws_region}.amazonaws.com/v1/logs + export OTEL_EXPORTER_OTLP_LOGS_HEADERS=x-aws-log-group=${var.test_log_group},x-aws-log-stream=default OTEL_RESOURCE_ATTRIBUTES=service.name=sample-remote-application-${var.test_id} \ nohup java -jar remote-service.jar &> nohup.out & diff --git a/terraform/java/ec2/adot-sigv4/variables.tf b/terraform/java/ec2/adot-sigv4/variables.tf index 4d861ee8b..acb69dc64 100644 --- a/terraform/java/ec2/adot-sigv4/variables.tf +++ b/terraform/java/ec2/adot-sigv4/variables.tf @@ -47,4 +47,8 @@ variable "language_version" { variable "cpu_architecture" { default = "x86_64" +} + +variable "test_log_group" { + default = "otlp_logs" } \ No newline at end of file diff --git a/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java b/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java index c51ca6309..b632bebb1 100644 --- a/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java +++ b/validator/src/main/java/com/amazon/aoc/fileconfigs/PredefinedExpectedTemplate.java @@ -116,23 +116,26 @@ public enum PredefinedExpectedTemplate implements FileConfig { JAVA_EC2_UBUNTU_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/ubuntu/client-call-trace.mustache"), /** Java EC2 ADOT SigV4 (ADOT Stand-Alone) Test Case Validations */ - JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-log.mustache"), + JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-log.mustache"), JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_METRIC( - "/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-metric.mustache"), + "/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-metric.mustache"), JAVA_EC2_ADOT_SIGV4_OUTGOING_HTTP_CALL_TRACE( - "/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-trace.mustache"), + "/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-trace.mustache"), - JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-log.mustache"), - JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_METRIC("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-metric.mustache"), - JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_TRACE("/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-trace.mustache"), + JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-log.mustache"), + JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-metric.mustache"), + JAVA_EC2_ADOT_SIGV4_AWS_SDK_CALL_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-trace.mustache"), - JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_LOG("/expected-data-template/java/ec2/adot-sigv4/remote-service-log.mustache"), - JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_METRIC("/expected-data-template/java/ec2/adot-sigv4/remote-service-metric.mustache"), - JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_TRACE("/expected-data-template/java/ec2/adot-sigv4/remote-service-trace.mustache"), + JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_LOG("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-log.mustache"), + JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-metric.mustache"), + JAVA_EC2_ADOT_SIGV4_REMOTE_SERVICE_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/remote-service-trace.mustache"), - JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_LOG("/expected-data-template/java/ec2/adot-sigv4/client-call-log.mustache"), - JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_METRIC("/expected-data-template/java/ec2/adot-sigv4/client-call-metric.mustache"), - JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/adot-sigv4/client-call-trace.mustache"), + JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_LOG("/expected-data-template/java/ec2/adot-aws-otlp/client-call-log.mustache"), + JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_METRIC("/expected-data-template/java/ec2/adot-aws-otlp/client-call-metric.mustache"), + JAVA_EC2_ADOT_SIGV4_CLIENT_CALL_TRACE("/expected-data-template/java/ec2/adot-aws-otlp/client-call-trace.mustache"), + + /** Java EC2 ADOT SigV4 Log Exporter Test Case Validation */ + JAVA_EC2_ADOT_OTLP_LOG("/expected-data-template/java/ec2/adot-aws-otlp/logs/application-log.mustache"), /** Java EC2 K8s Test Case Validations */ JAVA_K8S_OUTGOING_HTTP_CALL_LOG("/expected-data-template/java/k8s/outgoing-http-call-log.mustache"), diff --git a/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java b/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java index 4946c9084..49af8d396 100644 --- a/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java +++ b/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java @@ -236,7 +236,7 @@ private Map getActualOtelSpanLog(String operation, String remote private Map getActualAwsOtlpLog() throws Exception { String filterPattern= String.format( - "{ ($.attributes.otelServiceName = \"%s\") && ($.body = \"This is a custom log for validation testing\") }", + "{ ($.resource.attributes.['service.name'] = \"%s\") && ($.body = \"This is a custom log for validation testing\") }", context.getServiceName() ); log.info("Filter Pattern for OTLP Log Search: " + filterPattern); diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-log.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-log.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-log.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-log.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-metric.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-metric.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-metric.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-metric.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-trace.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-trace.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/aws-sdk-call-trace.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/aws-sdk-call-trace.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-log.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-log.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-log.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-log.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-metric.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-metric.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-metric.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-metric.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-trace.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-trace.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/client-call-trace.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/client-call-trace.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/logs/application-log.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/logs/application-log.mustache new file mode 100644 index 000000000..8eabbd12d --- /dev/null +++ b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/logs/application-log.mustache @@ -0,0 +1,16 @@ +[{ + "resource": { + "attributes": { + "service.name": "{{serviceName}}", + "cloud.provider": "aws", + "cloud.region": "{{region}}", + "cloud.account.id": "{{accountId}}", + "cloud.platform": "aws_ec2" + } + }, + "severityNumber": "^[0-9]+$", + "severityText": "{{severityText}}", + "body": "This is a custom log for validation testing", + "traceId": "{{traceId}}", + "spanId": "{{spanId}}" +}] \ No newline at end of file diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-log.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-log.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-log.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-log.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-metric.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-metric.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-metric.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-metric.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-trace.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-trace.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/outgoing-http-call-trace.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/outgoing-http-call-trace.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-log.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-log.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-log.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-log.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-metric.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-metric.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-metric.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-metric.mustache diff --git a/validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-trace.mustache b/validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-trace.mustache similarity index 100% rename from validator/src/main/resources/expected-data-template/java/ec2/adot-sigv4/remote-service-trace.mustache rename to validator/src/main/resources/expected-data-template/java/ec2/adot-aws-otlp/remote-service-trace.mustache diff --git a/validator/src/main/resources/validations/java/ec2/adot-sigv4/log-validation.yml b/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/log-validation.yml similarity index 100% rename from validator/src/main/resources/validations/java/ec2/adot-sigv4/log-validation.yml rename to validator/src/main/resources/validations/java/ec2/adot-aws-otlp/log-validation.yml diff --git a/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/logs/application-log-validation.yml b/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/logs/application-log-validation.yml new file mode 100644 index 000000000..e908a49a4 --- /dev/null +++ b/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/logs/application-log-validation.yml @@ -0,0 +1,3 @@ +- + validationType: "cw-log" + expectedLogStructureTemplate: "JAVA_EC2_ADOT_OTLP_LOG" \ No newline at end of file diff --git a/validator/src/main/resources/validations/java/ec2/adot-sigv4/metric-validation.yml b/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/metric-validation.yml similarity index 100% rename from validator/src/main/resources/validations/java/ec2/adot-sigv4/metric-validation.yml rename to validator/src/main/resources/validations/java/ec2/adot-aws-otlp/metric-validation.yml diff --git a/validator/src/main/resources/validations/java/ec2/adot-sigv4/trace-validation.yml b/validator/src/main/resources/validations/java/ec2/adot-aws-otlp/trace-validation.yml similarity index 100% rename from validator/src/main/resources/validations/java/ec2/adot-sigv4/trace-validation.yml rename to validator/src/main/resources/validations/java/ec2/adot-aws-otlp/trace-validation.yml