0

I have a AWS lambda function which has x-ray traces(subsegments) and from inside, there is an http call to a microservice(NodeJS- used fetch) which again has x-ray tracing implemented(subsegments). When I hit the service url of lambda function, two service maps are created in X-Ray : one for lambda and another for microservice. Is there anyway to have a single service map for both together? Can we pass trace id to the downstream http call(NodeJS- used fetch) to get a single service map ?

Ramya Karuna
  • 61
  • 2
  • 5

1 Answers1

1

The AWS X-Ray SDK can capture outgoing http requests. When it does, it will add an X-Amzn-Trace-Id header that will let instrumented downstream services know to continue a trace.

You'll need to patch the global http/https node.js modules with X-Ray in order for this header to be sent. You can use the AWSXRay.captureHttpsGlobal method, passing in either require('https') or require('http') as the argument. The reason you want to capture the module globally is because you are using fetch, which should use http/https behind the scenes.