Integrating AWS Xray with Loopback
AWS Xray and Loopback
AWS Xray is a service that helps you trace requests throughout a distributed application on AWS, and Loopback is a Node.js API framework, for quick and easy API building.
I added Xray to a loopback application (running on Elasticbeanstalk) and I couldn’t find any particular guidance on the correct way to do it. What I did is working, so I figured I would share.
How
I had to edit a single file in the loopback application and add a file to the deployment configuration to set up the server daemon to get this working, so it’s pretty simple.
1) Install AWS Xray package
|
|
2) Update server/server.js
All that’s required to get this working is requiring the module and then a few lines added to server.js, before starting the app.
|
|
|
|
3) Add file to .ebextensions/
This file will setup the Xray daemon on the EC2 instance. The daemon collects segments for multiple requests and updates the AWS Xray service with them in batches.
|
|
You can find information for other daemon setups @
That’s it
Theres more advanced things you can do with Xray and a lot more configuration options, I was mainly interested in testing it out and having a look around the service. You can find more information in the AWS Xray developer guide