Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling X-Ray support in AWS Lambda

I want to get some X-Ray traces of my Lambda function. From reading the documentation it seems I can just enable active tracing in the configuration and it should record it automatically without any new code deploys correct?

Only if I want custom sub segments would I explicitly make some X-Ray calls in the lambda function?

like image 440
MikanPotatos Avatar asked Jul 24 '26 20:07

MikanPotatos


1 Answers

Yes, you are correct, with the following caveats:

  1. You need to check the Enable Active Tracing checkbox in the Lambda console. From your function in the console > Configuration tab > Advanced dropdown/section > check Enable Active Tracing checkbox > Save.
  2. When you follow the step above, the console will advise that the IAM policy that the function executes under will be modified. If you're using a role created by the console when creating a function, you may need to modify the role manually. Either create a new policy and attach it to the role, create an inline policy attachment, or edit the existing policy for the role with a SID like this (this is an example - use globs in IAM policies with great care):

    {
        "Sid": "AllowXRay",
        "Resource": "*",
        "Action": [
            "xray:PutTraceSegments",
            "xray:PutTelemetryRecords"
        ],
        "Effect": "Allow"
    }
    

After following these steps, I was able to see full traces of my function in the XRay console.

like image 192
geekmuse Avatar answered Jul 28 '26 15:07

geekmuse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!