1

My stage has xray tracking enabled and I can see X-Amzn-Trace-Id is coming back from API gateway, moreover, I'm able to see the whole trace from APIG to Dynamo db. I would like to save this trace id to the table, so we can debug it more efficiently, but when I map an integration like

 "TableName" : "${aws_dynamodb_table.openApi_staging.id}",
    "Item": {
        "RequestId": {
            "S": "$context.requestId"
            },
        "Request": {
            "S": "$input.path('$')"
            },
        "RequestedAt": {
            "S": "$context.requestTime"
            },
        "Status":{
            "S": "New"
            },
        "Xray": {
          "S": "_$context.xrayTraceId"
        }

    }

Xray is always empty! How can I obtain this id?

nelly2k
  • 781
  • 1
  • 10
  • 28
  • Is is the underscore? Why "_$context.xrayTraceId" and not "$context.xrayTraceId"? Are the other values like requestid set correct? – TheClassic May 08 '20 at 16:02
  • underscore it there just because I need to pass something g to dynamo, it doesn't support empty values – nelly2k May 12 '20 at 01:46

1 Answers1

0

Ok, it seems that solution from aws documentation doesn't work, however Xray id present in headers, so we can do

 "Xray": {
          "S": "$method.request.header.X-Amzn-Trace-Id"
        }

and that works!

nelly2k
  • 781
  • 1
  • 10
  • 28