How to use the aws-xray-sdk-core.getNamespace 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 terodox / aws-xray-lambda-promise-subsegment / demo / index.js View on Github external
return new Promise(resolve => {
        AWSXRay.setDaemonAddress('127.0.0.1:2000');
        AWSXRay.enableAutomaticMode();

        const segment = new AWSXRay.Segment('aws-xray-lambda-promise-subsegment');
        const namespace = AWSXRay.getNamespace();

        namespace.run(async function () {
            AWSXRay.setSegment(segment);
console.log('segment', segment);
            try {
                await functionToHaveTraced(segment);
                segment.close();
            } catch (error) {
                console.error(error);
                segment.close(error);
            }
            resolve();
        });
    });
}
github aws / aws-xray-sdk-node / packages / mysql / lib / mysql_p.js View on Github external
args.callback = function autoContext(err, data) {
          var session = AWSXRay.getNamespace();

          session.run(function() {
            AWSXRay.setSegment(subsegment);
            cb(err, data);
          });

          subsegment.close(err);
        };
      } else {
github aws / aws-xray-sdk-node / packages / express / lib / express_mw.js View on Github external
segment.addThrottleFlag();
        if (AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode))
          segment[AWSXRay.utils.getCauseTypeFromHttpStatus(this.statusCode)] = true;

        segment.http.close(this);
        segment.close();

        AWSXRay.getLogger().debug('Closed express segment successfully: { url: ' + req.url + ', name: ' + segment.name + ', trace_id: ' +
          segment.trace_id + ', id: ' + segment.id + ', sampled: ' + !segment.notTraced + ' }');
      };

      res.on('finish', endSegment);
      res.on('close', endSegment);

      if (AWSXRay.isAutomaticMode()) {
        var ns = AWSXRay.getNamespace();
        ns.bindEmitter(req);
        ns.bindEmitter(res);

        ns.run(function () {
          AWSXRay.setSegment(segment);

          if (next) { next(); }
        });
      } else {
        req.segment = segment;
        if (next) { next(); }
      }
    };
  },
github aws / aws-xray-sdk-node / packages / postgres / lib / postgres_p.js View on Github external
args.callback = function autoContext(err, data) {
        var session = AWSXRay.getNamespace();

        session.run(function() {
          AWSXRay.setSegment(subsegment);
          cb(err, data);
        });

        subsegment.close(err);
      };
    } else {