2

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?

MikanPotatos
  • 143
  • 1
  • 2
  • 9

1 Answers1

4

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.

geekmuse
  • 360
  • 1
  • 5
  • Adding these worked. Unfo, the incoming JSON is not logged...add to the one Statement object already there. "xray:PutTraceSegments", "xray:PutTelemetryRecords" – codeslapper Jun 21 '17 at 20:22