Open zhaoyi0113 opened 1 year ago
This panic is xray sdk creates a subsegment but cannot find available parent segment from context, it happens in asynchronous case for example:
seg, ctx := xray.BeginSegment()
defer seg.Close()
go xray.BeginSubsegment(ctx) // create subsegment after parent segment is closed.
So, probably your putItem
method is running in async case but query
is not.
Alternatively, user can use ADOT, it is xray's long term strategy to move from xray sdk to ADOT. ADOT supports async in a better solution, would not have context missing panic. Please refer to a Lambda go example https://aws-otel.github.io/docs/getting-started/lambda/lambda-go
I am not running anything inside go routine, there should not be any async calls.
My application is running inside lambda and I thought the segment is created by lambda automatically. I don't need to call BeginSegment
in my code for automatic tracing?
In AWS Lambda scenario, X-Ray SDK will automatically find parent trace context from Lambda environment variable _X_AMZN_TRACE_ID, user no need call BeginSegment
.
But it only works inside of user Lambda handler function. If user instruments his aws sdk and makes a call before Lambda handler function it will show segment cannot be found.
error.
client = xray.instrument(client)
client.call() // not support, Lambda does not env variable _X_AMZN_TRACE_ID yet
handler() {
client.call() // support, because there is env variable _X_AMZN_TRACE_ID
}
I am deploying code to Lambda and use below code to instrument dynamodb requests. It works fine for
query
but doesn't work forputItem
.I got below error:
Is there any other configuration needed for
putItem
?