aws-xray-sdk-go icon indicating copy to clipboard operation
aws-xray-sdk-go copied to clipboard

Tracing into another lambda

Open kaihendry opened this issue 4 years ago • 6 comments

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?

kaihendry avatar Aug 12 '21 10:08 kaihendry

I created a minimal code example here: https://github.com/kaihendry/x-amzn-trace-id to reproduce my problem

kaihendry avatar Aug 14 '21 10:08 kaihendry

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?

bhautikpip avatar Aug 17 '21 20:08 bhautikpip

tracing-TIL

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?

kaihendry avatar Aug 18 '21 04:08 kaihendry

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.

bhautikpip avatar Aug 23 '21 20:08 bhautikpip

Two appended headers is what I observed here: https://github.com/kaihendry/sam-header-test

kaihendry avatar Aug 24 '21 03:08 kaihendry

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.

stale[bot] avatar Jan 09 '22 01:01 stale[bot]