简体   繁体   中英

AWS x-ray not generating

I am trying to generate an x-ray using aws x-ray but it is not generating. Currently I am generating it for a lambda function in node.js

async function geUser(event, context) {

    await someFunction();
    const segment = new AWSXRay.Segment('getUser');
    segment.close();
    return 'success';
};

I have tried below example but still it's not generating

async function getUser(event, context) {

    await someFunction();
    AWSXRay.captureFunc('annotations', function(subsegment){
        console.log('xraysubsegment', subsegment);
        subsegment.addAnnotation('LambdaFunction', 'getUser');
        subsegment.addAnnotation('UserID', id);
    });
    return 'success';
};

and in serverless.yml

iamRoleStatements:
    - Effect: "Allow" 
      Action:
        - "xray:PutTraceSegments"
        - "xray:PutTelemetryRecords"
      Resource: "*"

Is there anything I am missing

To use X-Ray in a Lambda function, you need to enable X-Ray for that Lambda function.
In the console this is done under the "Debuggin and error handling configuration section", the configuration is called "Enable active tracing".

See the documentation for further details.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM