How to use the aws-xray-sdk-core.capturePromise function in aws-xray-sdk-core

To help you get started, we’ve selected a few aws-xray-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simalexan / api-lambda-stripe-charge / src / tracing-repository.js View on Github external
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AWSXRay = require('aws-xray-sdk-core');
AWSXRay.capturePromise();
// Makes sure that this function is not called again.
// It would wrap the promise prototype multiple times.
AWSXRay.capturePromise = function () { };
function captureAsyncFunc(name, func) {
    return new Promise(function (resolve, reject) {
        AWSXRay.captureAsyncFunc(name, (segment) => {
            func(segment).then((result) => {
                segment.close();
                resolve(result);
            }, (error) => {
                segment.close(error);
                reject(error);
            });
        });
    });
}
github lifeomic / lambda-tools / src / xray.js View on Github external
exports.captureWithXRay = function (awsSdk) {
  const xray = require('aws-xray-sdk-core');

  xray.captureHTTPsGlobal(require('http'));
  xray.capturePromise();
  return xray.captureAWS(awsSdk);
};