aws / aws-xray-sdk-go

AWS X-Ray SDK for the Go programming language.
Apache License 2.0
278 stars 118 forks source link

Tracing into another lambda #326

Open kaihendry opened 3 years ago

kaihendry commented 3 years ago

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 commented 3 years ago

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

bhautikpip commented 3 years ago

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?

kaihendry commented 3 years ago

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?

bhautikpip commented 3 years ago

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.

kaihendry commented 3 years ago

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

stale[bot] commented 2 years ago

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.