
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
aws-xray-sdk-restify
Advanced tools
The AWS X-Ray Restify package automatically records information for incoming and outgoing requests and responses, via the 'enable' function in this package. To configure sampling, dynamic naming, and more see the set up section.
The AWS X-Ray SDK Core has two modes - manual
and automatic
.
Automatic mode uses the cls-hooked
package and automatically
tracks the current segment and subsegment. This is the default mode.
Manual mode requires that you pass around the segment reference.
In automatic mode, you can get the current segment or subsegment at any time:
var segment = AWSXRay.getSegment();
In manual mode, you can get the base segment off of the request object:
var segment = req.segment;
//If the restify context plugin is being used, it is placed under 'XRaySegment'
var segment = req.get('XRaySegment');
The X-Ray SDK provides a single Restify middleware:
AWSXRayRestify.enable(<server>, <defaultName>)
. This must be added as the last middleware before defining all routes you'd like to have traced, otherwise issues with the cls-hooked
context may occur. Error capturing will be done automatically.
For more automatic mode examples, see the example code.
var AWSXRayRestify = require('aws-xray-sdk-restify');
var restify = require('restify');
var server = restify.createServer();
//...
AWSXRayRestify.enable(server, 'defaultName');
server.get('/', function (req, res) {
var segment = AWSXRay.getSegment();
//...
res.send('hello');
});
//Error capturing is attached to the server's uncaughtException and after events (for both handled and unhandled errors)
For more manual mode examples, see manual mode examples. The X-Ray SDK can be used identically inside Restify routes. Note that you don't have to manually start or close the segments since that is handled by the X-Ray middleware.
var AWSXRayRestify = require('aws-xray-sdk-restify');
var restify = require('restify');
var server = restify.createServer();
//...
AWSXRayRestify.enable(server, 'defaultName'); //Required at the start of your routes
server.get('/', function (req, res) {
var segment = req.segment;
//...
res.send('hello');
});
//Error capturing is attached to the server's uncaughtException and after events (for both handled and unhandled errors)
FAQs
Enables AWS X-Ray for Restify (Javascript)
The npm package aws-xray-sdk-restify receives a total of 1,068 weekly downloads. As such, aws-xray-sdk-restify popularity was classified as popular.
We found that aws-xray-sdk-restify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 25 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.