aws-xray-sdk-go
aws-xray-sdk-go copied to clipboard
Tracing into another lambda
I have some code that looks like:
getAddress := "https://xyz.execute-api.us-east-1.amazonaws.com/metrics"
// trace request with Xray
ctx, root := xray.BeginSegment(context.Background(), "fetch another microservice")
resp, err := ctxhttp.Get(ctx, xray.Client(http.DefaultClient), getAddress)
if err != nil {
log.WithField("url", getAddress).WithError(err).Error("failed to fetch")
}
Though in Service Lens, it doesn't seem able to realise than "xyz" is another AWS microservice (in the same account) that I also want to trace and see inline. What am I missing?
I created a minimal code example here: https://github.com/kaihendry/x-amzn-trace-id to reproduce my problem
If I understand your use case then you want to see Remote node as a microservice? Also, I think as per current scenario you are doing HTTP call from fetch another microservice which is instrumented with X-Ray Go SDK. If downstream service is not instrumented with X-Ray then it would mark this node as Remote and that is the reason you're seeing Remote node. Which downstream service you're calling?

I think my confusion comes by how the x-amzn-trace-id is passed along the microservices. Lets just call them "a" & "b".
IIUC when "a" is invoked, and then calls "b", which responds all the way back down, there are two appended x-amzn-trace-id headers?
Not sure if I understand this correctly, but why would there be two appended headers? Ideally microservice "a" generates and propagates header to downstream service which downstream service "b" uses while making a sampling decision. The important thing to note is microservice "b" should be instrumented with X-Ray SDK.
Two appended headers is what I observed here: https://github.com/kaihendry/sam-header-test
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in next 7 days. Thank you for your contributions.