Kylian Rey
Kylian Rey

Reputation: 11

How to implement XRay in NodeJS project?

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!

Upvotes: 0

Views: 456

Answers (2)

Piyush Mattoo
Piyush Mattoo

Reputation: 16105

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

Upvotes: 0

Jonathan Lee
Jonathan Lee

Reputation: 36

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

Upvotes: 1

Related Questions