Home > Back-end >  How to implement XRay in NodeJS project?
How to implement XRay in NodeJS project?

Time:01-24

I've a nodejs project with Docker and ECS in AWS , and i need to implement XRay to get the traces but I couldn't get it to work yet

I installed 'aws-xray-sdk' (npm install aws-xray-sdk), then I added const AWSXRay = require('aws-xray-sdk'); in app.js Then, before the routes I added app.use(AWSXRay.express.openSegment('Example')); and after the routes: app.use(AWSXRay.express.closeSegment());

I hit some endpoints but I can't see any trace or data in xray, maybe do I need to setup something in AWS ? I have a default group in xray. Thanks!

CodePudding user response:

It sounds like you do not have the XRay Daemon running in your ECS environment. This daemon must be used in conjunction with the SDKs to send the trace data to AWS XRay service from the SDKs. The daemon listens for the trace data traffic on UDP port 2000. Read more about the daemon here: https://docs.aws.amazon.com/xray/latest/devguide/xray-daemon.html

See how to run the XRay Daemon on ECS via Docker here: https://docs.aws.amazon.com/xray/latest/devguide/xray-daemon-ecs.html

CodePudding user response:

You would either need to look at X-Ray SDK, Agent or Open Telemetry SDK, Collector (AWS Distro for Open Telemetry)

  • Related