I have the following lambda function.
import * as xray from 'aws-xray-sdk';
import * as http from 'http';
import * as https from 'https';
// This is my business logic
import {handler} from './handler';
xray.enableManualMode();
xray.capturePromise();
export async function myLambda(
event: {
traceId: string // from another service
parentSegmentId: string // segment id of the service which generate this event
},
context: Context
) {
const parentSegment = new xray.Segment(context.functionName, event.traceId, event.parentSegmentId);
xray.setSegment(parentSegment);
parentSegment.addMetadata('event', event);
xray.captureHTTPsGlobal(http);
xray.captureHTTPsGlobal(https);
try {
await handler(event);
parentSegment.close();
} catch (err) {
parentSegment.addError(error);
parentSegment.close();
throw err;
}
}
When I call my lambda function via SQS, I get the below-mentioned error (in my cloudwatch logs).
Error: No sub/segment specified. A sub/segment must be provided for manual mode. at Object.contextMissingLogError [as contextMissing] (/var/task/webpack:/home/ct/node_modules/aws-xray-sdk-core/lib/context_utils.js:26:1) at Object.resolveSegment (/var/task/webpack:/home/ct/node_modules/aws-xray-sdk-core/lib/context_utils.js:77:1) at captureOutgoingHTTPs (/var/task/webpack:/home/ct/node_modules/aws-xray-sdk-core/lib/patchers/http_p.js:66:1) at Object.captureHTTPsRequest [as request]
I'm currently using v2.4.0 of
x-ray nodejs sdk.
Can anyone help me with this?
This question is being answered on GitHub: https://github.com/aws/aws-xray-sdk-node/issues/214
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.