To monitor detailed performance and draw the path of requests (Service Map) throughout the system—from the API Gateway, through the Step Functions state machine, down to each executing Lambda function—we need to enable AWS X-Ray.
API Gateway acts as the entry point, generating the initial Trace ID to pass along the processing flow.
Go to the API Gateway service on the AWS Console.
Click on the project’s API name: docuflow-dev-api.
On the left vertical menu, select Stages.
Click on the name of the running stage (For example: dev or v1).
Switch to the Logs/Tracing tab on the right interface panel.
Find the X-Ray Tracing section ➔ Check the Enable X-Ray Tracing box.

Click the Save changes button at the bottom to save the configuration.

Helps the state machine inherit the Trace ID from API Gateway and forward it to Lambda tasks.
Go to the Step Functions service on the AWS Console.
Select the project’s State Machine: docuflow-dev-workflow-processing-state-machine.

In the top right corner, click the Edit button.
Scroll down to the bottom of the configuration page and find the Tracing (or Additional configuration) section.
Check the Enable X-Ray tracing box.

Click the Save button in the top right corner to update.

You need to manually enable Active Tracing for each Lambda function so X-Ray can record detailed code execution logs:
docuflow-dev-api-generate-upload-url-lambdadocuflow-dev-ingestion-job-starter-lambdadocuflow-dev-workflow-validate-lambdadocuflow-dev-ai-textract-lambdadocuflow-dev-ai-proxy-lambdadocuflow-dev-ai-confidence-status-lambdadocuflow-dev-data-get-document-lambdadocuflow-dev-data-list-documents-lambdaClick on the name of the first Lambda function in the list.

Select the Configuration tab (next to the Code tab).
Look at the left vertical menu in the tab and select Monitoring and tools.

In the top right corner of the content panel, click the Edit button.
Scroll down to find the Lambda service traces line ➔ Check Enable.

Click the orange Save button at the bottom to apply.

Do the same for the remaining 7 Lambda functions, one by one.
When Active Tracing is enabled for Lambda, the Lambda code must have permission to send trace telemetry data back to the CloudWatch X-Ray daemon. If permissions are missing, the processing flow might be interrupted:
docuflow-dev-data-lambda-role, docuflow-dev-security-ai-proxy-role,…).AWSXRayDaemonWriteAccess.API Gateway ➔ Step Functions ➔ Lambdas ➔ DynamoDB / Textract.