We are testing AWS XRay with basic nodejs config as per the XRay getting started, however an error is being thrown. Its a dummy express app, Lambda on Node 4.3, so should work. The error is
Error: EROFS: read-only file system, open 'AWSXRay.log' at Error (native)
Any thoughts ?
Thanks
Dave
AWS X-Ray SDK for JavaScript will log the messages to a file using a logging library but since you are running on Lambda, you don't really have access to create files on the file system.
Currently AWS X-Ray is not supported on Lambda but will be supported in the future.
As a temporary workaround you could try overriding the logger in your lambda function using something like this:
var logger = require('aws-xray-sdk/lib/logger');
logger.error = function(string) { console.error(string); };
logger.info = function(string) { console.info(string); };
logger.warn = function(string) { console.warn(string); };
Can you try with this workaround?
Along with instrumenting your application code you will also need to send segments / subsegments to the X-Ray backend. Outside of lambda, you would typically have the xray daemon running on your machine and the SDK will send segments over UDP to localhost. The daemon would buffer and send data to X-Ray using the AWS SDK. On lambda you currently won't have this facility as you won't have a daemon running along with your lambda function. This means currently you can use the SDK to manually construct segments / subsegments then use the AWS SDK to send data to the backend. This is however not the recommended best practice since the daemon does buffering for you if you are sending lots of segments. If you are using the low level SDK you will have to manage buffering on your own.
You could use the above workaround and see if it works for you. The recommended approach is to wait for Lambda integration with AWS X-Ray.