Description
In Active mode, Lambda automatically sends traces for sampled invocations to X-Ray. PassThrough forwards trace context. Function code can still emit its own traces.
Potential impact
Logs and metrics alone may not show which call in a chain of services caused a delay or error.
Remediation
For automatic tracing, set tracing_config.mode to Active and grant the execution role X-Ray write permissions. Check for sampled traces after invoking the function. Instrument downstream calls if you need their timing, and keep logs and metrics for broader coverage.
Examples
Both excerpts reference the same ZIP package, handler and execution role. Supply the package and role and select a supported runtime compatible with the handler.
Before
resource "aws_lambda_function" "example" {
filename = "lambda_function_payload.zip"
function_name = "lambda_function_name"
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.test"
tracing_config {
mode = "PassThrough"
}
}
After
resource "aws_lambda_function" "example" {
filename = "lambda_function_payload.zip"
function_name = "lambda_function_name"
role = aws_iam_role.iam_for_lambda.arn
handler = "exports.test"
tracing_config {
mode = "Active"
}
}