aws-xray-sdk-go: "segment cannot be found" in lambda function
I’m new to X-Ray and am trying to integrate it into a Lambda function called from API Gateway as a Lambda proxy integration request. My code follows this example:
xray.Configure(xray.Config{LogLevel: "trace"})
sess := session.Must(session.NewSession())
dynamo := dynamodb.New(sess)
xray.AWS(dynamo.Client)
This results in the following error being logged Error Suppressing AWS X-Ray context missing panic: failed to begin subsegment named 'dynamodb': segment cannot be found.
, which is followed by a panic runtime error: invalid memory address or nil pointer dereference
in the xray SDK when the first DynamoDB operation executes.
I can “fix” this by creating a new segment with xray.BeginSegment
, which puts a new service node in the graph.
I have tried this both with “active tracing” enabled and disabled in the Lambda config. When enabled, I get 2 more nodes for the Lambda service and function in the graph, but they’re not connected to the new segment I create in the function as described above.
I am not sure if I’m doing something wrong (in which case the example would seem wrong too) or if this is a bug.
It also worries me that this results in a panic that propagates to my Lambda, because even if I fix this particular problem, I don’t like the idea of a library that just instruments my code potentially causing a fatal error of the lambda.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 36 (13 by maintainers)
@aleist, sorry for the late reply. During the debug process, I just realized Lambda support starting from version
v1.0.0-rc.1
and you are usingv0.9.4
. So please update the X-Ray Go SDK tov1.0.0-rc.2
since I found a bug in our latest release and fix is under code review. I am sorry for the inconvenience.Even I’m facing exactly the same issue.
go version go1.13.1 linux/amd64 github.com/aws/aws-xray-sdk-go v1.0.0-rc.14
@luluzhao we are getting the same bug:
Suppressing AWS X-Ray context missing panic: failed to begin subsegment named 'dynamodb': segment cannot be found.
After which a nil pointer error is thrown. We’ve tried version 0.9.4, rc2 and rc3. It happens on all three.
Here is some code: