我正在尝试在没有快速中间件的情况下将一些数据跟踪到 AWS Xray。我的代码如下:
const AWSXRay = require('aws-xray-sdk'),
AWS = AWSXRay.captureAWS(require('aws-sdk')),
sqs = AWSXRay.captureAWSClient(new AWS.SQS({apiVersion: '2012-11-05', region: 'eu-west-1'}));
AWSXRay.enableManualMode();
var segment = new AWSXRay.Segment('sqsSegment');
var params = {
QueueUrl: "https://sqs.eu-west-1.amazonaws.com/123/queuename",
VisibilityTimeout: 0,
WaitTimeSeconds: 0,
XraySegment: segment
};
sqs.receiveMessage(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
segment.close();
我收到错误:Error: No sub/segment specified. A sub/segment must be provided for manual mode.
我正在创建一个段并通过参数将其传递给receiveMessage。但它似乎不起作用。有任何想法吗?