Skip to content

Cross language validation#619

Open
Miqueasher wants to merge 17 commits intomainfrom
Cross_Language_Validation
Open

Cross language validation#619
Miqueasher wants to merge 17 commits intomainfrom
Cross_Language_Validation

Conversation

@Miqueasher
Copy link
Copy Markdown
Contributor

@Miqueasher Miqueasher commented Apr 15, 2026

Adds standardized log schema validation that runs on every Lambda E2E test
for Python, Java, JS, and .NET.
Validates that both OTEL_LOGS_EXPORTER=console
and OTLP export paths produce logs matching the CloudWatch OTLP backend's
flattened 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 exportPath field
    as 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.

  • 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.

@Miqueasher Miqueasher requested a review from wangzlei April 15, 2026 15:58
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Contributor

@wangzlei wangzlei Apr 16, 2026

Choose a reason for hiding this comment

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

Is OTEL_EXPORTER_OTLP_LOGS_PROTOCOL= "http/protobuf" required for Java/Node?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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$",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there difference we need a .net specific log mustache?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]+$",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How can we ensure that the nano time value of this Console exporter is exactly the same as that of OTLP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

2 participants