Cross language validation#619
Conversation
| AWS_LAMBDA_EXEC_WRAPPER = "/opt/otel-instrument" | ||
| OTEL_SERVICE_NAME = "${var.function_name}" | ||
| AWS_LAMBDA_EXEC_WRAPPER = "/opt/otel-instrument" | ||
| AWS_LAMBDA_HANDLER_LOG_FORMAT = "Unformatted" |
There was a problem hiding this comment.
Is AWS_LAMBDA_HANDLER_LOG_FORMAT required for .Net logs? If yes, we need to update https://aws-otel.github.io/docs/getting-started/lambda#logs-exporter later.
There was a problem hiding this comment.
It's necessary to format the logs correctly for our validation template.
| OTEL_LOGS_EXPORTER = "otlp,console" | ||
| OTEL_EXPORTER_OTLP_LOGS_ENDPOINT = "https://logs.${var.region}.amazonaws.com/v1/logs" | ||
| OTEL_EXPORTER_OTLP_LOGS_HEADERS = "x-aws-log-group=/aws/lambda/${var.function_name},x-aws-log-stream=otlp-logs" | ||
| OTEL_EXPORTER_OTLP_LOGS_PROTOCOL = "http/protobuf" |
There was a problem hiding this comment.
Is OTEL_EXPORTER_OTLP_LOGS_PROTOCOL= "http/protobuf" required for Java/Node?
There was a problem hiding this comment.
For Java yes, but for Node not exactly. It keeps consistency and avoids having to rely on a fall back though.
| "faas.version": "^.+$", | ||
| "faas.instance": "^.+$", | ||
| "aws.log.group.names": "^/aws/lambda/{{serviceName}}$", | ||
| "telemetry.sdk.language": "^dotnet$", |
There was a problem hiding this comment.
Is there difference we need a .net specific log mustache?
There was a problem hiding this comment.
From observed differences .NET's observedTimeUnixNano is always 0 because the .NET LogRecord doesn't expose observed timestamp → template uses ^[0-9]+$
So unless that changes we need a separate file otherwise the validation templates won't work
| "severityText": "^(?i)(TRACE|DEBUG|INFO|WARN|ERROR|FATAL)$", | ||
| "droppedAttributes": "^[0-9]+$", | ||
| "timeUnixNano": "^[1-9][0-9]+$", | ||
| "observedTimeUnixNano": "^[1-9][0-9]+$", |
There was a problem hiding this comment.
How can we ensure that the nano time value of this Console exporter is exactly the same as that of OTLP
There was a problem hiding this comment.
they're not exactly the same value, they're the same format and field name, but different actual values because they're captured at different moments.
Adds standardized log schema validation that runs on every Lambda E2E test
for Python, Java, JS, and .NET.
Validates that both
OTEL_LOGS_EXPORTER=consoleand
OTLPexport paths produce logs matching the CloudWatch OTLP backend'sflattened JSON format (timeUnixNano, scope, flags, preserved attribute types).
Changes:
New validation templates: log-schema.mustache (console, 23 fields),
log-schema-otlp.mustache (OTLP core, 17 fields),
log-schema-dotnet.mustache (.NET console, observedTimeUnixNano allows 0)
Console and OTLP paths validated independently using
exportPathfieldas discriminator — console logs include
"exportPath":"console",OTLP logs do not (field not in protobuf schema)
Templates validate 11 resource attributes, scope, severity, timestamps,
trace context, body, and exportPath against strict regex patterns
Terraform: all 4 languages configured with OTEL_LOGS_EXPORTER=otlp,console,
OTLP endpoint/headers, pre-created otlp-logs stream, and language-specific
env vars (JUL instrumentation for Java, http/protobuf protocol for Java/JS,
Unformatted log format for .NET)
Workflows: log-schema-validation step added to all 4 lambda-test workflows,
included in pass/fail result check
<Can we safely revert this commit if needed? If not, detail what must be done to safely revert and why it is needed.>
Yes, a revert of this PR will safely revert everything.
For each language (Python, Java, JS), I :
Built the Lambda layer from source (includes the updated CompactConsoleLogRecordExporter)
Built the sample app with logging calls at multiple severity levels
Deployed to AWS account 978751493859 via terraform apply (same Terraform configs in this PR)
Invoked the Lambda via API Gateway
Verified console logs appeared in CloudWatch with correct OTLP-aligned JSON schema
Verified OTLP logs appeared in the otlp-logs stream
Ran the validator against both paths using the exact templates and configs in this PR
Validator returned BUILD SUCCESSFUL / Log validation is passed
Also created test-log-schema-validation.yml
This let us test the full validation pipeline (Terraform → deploy → invoke → validate → teardown) without needing the language repo changes merged first. It was used to iterate on the template format, CW filter patterns, and Terraform env vars until validation passed
NOTE: TESTS RUNNING ON A SINGLE EKS CLUSTER CANNOT BE RUN IN PARALLEL. See the needs keyword to run tests in succession.
e2e-playgroundin us-east-1 and eu-central-2e2e-playgroundin us-east-1 and eu-central-2e2e-playgroundin us-east-1 and eu-central-2By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.